mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	can: add protocol counter for AF_CAN sockets
The third column in the output of the following command: | # grep CAN /proc/net/protocols is systematically '0': use sock_prot_inuse_add() to account for the number of sockets for each protocol on top of AF_CAN family. Signed-off-by: Davide Caratti <dcaratti@redhat.com> Link: https://patch.msgid.link/9db5d0e6c11b232ad895885616f1258882a32f61.1741952160.git.dcaratti@redhat.com Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
This commit is contained in:
		
							parent
							
								
									958ee3d715
								
							
						
					
					
						commit
						6bffe88452
					
				
					 4 changed files with 8 additions and 1 deletions
				
			
		| 
						 | 
					@ -172,6 +172,8 @@ static int can_create(struct net *net, struct socket *sock, int protocol,
 | 
				
			||||||
		sock_orphan(sk);
 | 
							sock_orphan(sk);
 | 
				
			||||||
		sock_put(sk);
 | 
							sock_put(sk);
 | 
				
			||||||
		sock->sk = NULL;
 | 
							sock->sk = NULL;
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
							sock_prot_inuse_add(net, sk->sk_prot, 1);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 errout:
 | 
					 errout:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1625,6 +1625,7 @@ static int bcm_release(struct socket *sock)
 | 
				
			||||||
	sock->sk = NULL;
 | 
						sock->sk = NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	release_sock(sk);
 | 
						release_sock(sk);
 | 
				
			||||||
 | 
						sock_prot_inuse_add(net, sk->sk_prot, -1);
 | 
				
			||||||
	sock_put(sk);
 | 
						sock_put(sk);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1239,6 +1239,7 @@ static int isotp_release(struct socket *sock)
 | 
				
			||||||
	sock->sk = NULL;
 | 
						sock->sk = NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	release_sock(sk);
 | 
						release_sock(sk);
 | 
				
			||||||
 | 
						sock_prot_inuse_add(net, sk->sk_prot, -1);
 | 
				
			||||||
	sock_put(sk);
 | 
						sock_put(sk);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -397,11 +397,13 @@ static int raw_release(struct socket *sock)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct sock *sk = sock->sk;
 | 
						struct sock *sk = sock->sk;
 | 
				
			||||||
	struct raw_sock *ro;
 | 
						struct raw_sock *ro;
 | 
				
			||||||
 | 
						struct net *net;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!sk)
 | 
						if (!sk)
 | 
				
			||||||
		return 0;
 | 
							return 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ro = raw_sk(sk);
 | 
						ro = raw_sk(sk);
 | 
				
			||||||
 | 
						net = sock_net(sk);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	spin_lock(&raw_notifier_lock);
 | 
						spin_lock(&raw_notifier_lock);
 | 
				
			||||||
	while (raw_busy_notifier == ro) {
 | 
						while (raw_busy_notifier == ro) {
 | 
				
			||||||
| 
						 | 
					@ -421,7 +423,7 @@ static int raw_release(struct socket *sock)
 | 
				
			||||||
			raw_disable_allfilters(dev_net(ro->dev), ro->dev, sk);
 | 
								raw_disable_allfilters(dev_net(ro->dev), ro->dev, sk);
 | 
				
			||||||
			netdev_put(ro->dev, &ro->dev_tracker);
 | 
								netdev_put(ro->dev, &ro->dev_tracker);
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			raw_disable_allfilters(sock_net(sk), NULL, sk);
 | 
								raw_disable_allfilters(net, NULL, sk);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -440,6 +442,7 @@ static int raw_release(struct socket *sock)
 | 
				
			||||||
	release_sock(sk);
 | 
						release_sock(sk);
 | 
				
			||||||
	rtnl_unlock();
 | 
						rtnl_unlock();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						sock_prot_inuse_add(net, sk->sk_prot, -1);
 | 
				
			||||||
	sock_put(sk);
 | 
						sock_put(sk);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue