浏览代码

netfilter: remove unneccessary checks from netlink notifiers

The NETLINK_URELEASE notifier is only invoked for bound sockets, so
there is no need to check ->pid again.

Signed-off-by: Patrick McHardy <kaber@trash.net>
Patrick McHardy 15 年之前
父节点
当前提交
dee5817e88
共有 4 个文件被更改,包括 4 次插入8 次删除
  1. 1 2
      net/ipv4/netfilter/ip_queue.c
  2. 1 2
      net/ipv6/netfilter/ip6_queue.c
  3. 1 2
      net/netfilter/nfnetlink_log.c
  4. 1 2
      net/netfilter/nfnetlink_queue.c

+ 1 - 2
net/ipv4/netfilter/ip_queue.c

@@ -497,8 +497,7 @@ ipq_rcv_nl_event(struct notifier_block *this,
 {
 {
 	struct netlink_notify *n = ptr;
 	struct netlink_notify *n = ptr;
 
 
-	if (event == NETLINK_URELEASE &&
-	    n->protocol == NETLINK_FIREWALL && n->pid) {
+	if (event == NETLINK_URELEASE && n->protocol == NETLINK_FIREWALL) {
 		write_lock_bh(&queue_lock);
 		write_lock_bh(&queue_lock);
 		if ((n->net == &init_net) && (n->pid == peer_pid))
 		if ((n->net == &init_net) && (n->pid == peer_pid))
 			__ipq_reset();
 			__ipq_reset();

+ 1 - 2
net/ipv6/netfilter/ip6_queue.c

@@ -499,8 +499,7 @@ ipq_rcv_nl_event(struct notifier_block *this,
 {
 {
 	struct netlink_notify *n = ptr;
 	struct netlink_notify *n = ptr;
 
 
-	if (event == NETLINK_URELEASE &&
-	    n->protocol == NETLINK_IP6_FW && n->pid) {
+	if (event == NETLINK_URELEASE && n->protocol == NETLINK_IP6_FW) {
 		write_lock_bh(&queue_lock);
 		write_lock_bh(&queue_lock);
 		if ((n->net == &init_net) && (n->pid == peer_pid))
 		if ((n->net == &init_net) && (n->pid == peer_pid))
 			__ipq_reset();
 			__ipq_reset();

+ 1 - 2
net/netfilter/nfnetlink_log.c

@@ -666,8 +666,7 @@ nfulnl_rcv_nl_event(struct notifier_block *this,
 {
 {
 	struct netlink_notify *n = ptr;
 	struct netlink_notify *n = ptr;
 
 
-	if (event == NETLINK_URELEASE &&
-	    n->protocol == NETLINK_NETFILTER && n->pid) {
+	if (event == NETLINK_URELEASE && n->protocol == NETLINK_NETFILTER) {
 		int i;
 		int i;
 
 
 		/* destroy all instances for this pid */
 		/* destroy all instances for this pid */

+ 1 - 2
net/netfilter/nfnetlink_queue.c

@@ -574,8 +574,7 @@ nfqnl_rcv_nl_event(struct notifier_block *this,
 {
 {
 	struct netlink_notify *n = ptr;
 	struct netlink_notify *n = ptr;
 
 
-	if (event == NETLINK_URELEASE &&
-	    n->protocol == NETLINK_NETFILTER && n->pid) {
+	if (event == NETLINK_URELEASE && n->protocol == NETLINK_NETFILTER) {
 		int i;
 		int i;
 
 
 		/* destroy all instances for this pid */
 		/* destroy all instances for this pid */