Skip to contentSkip to conversation

netfilter: ctnetlink: allow changing NAT sequence adjustment in creation

PATCH In review Pablo Neira Ayuso 2 participants 4 messages Jan 27, 2009 – Feb 9, 2009

Subsystems (2)
lore
Share & tools
lore

Pablo Neira Ayuso

author maintainer
#0 lore raw

PATCH 1/2 netfilter: ctnetlink: allow changing NAT sequence adjustment in creation

This patch fixes an inconsistency in the current ctnetlink code since NAT sequence adjustment bit can only be updated but not set in the conntrack entry creation.

This patch is used by conntrackd to successfully recover newly created entries that represent connections with helpers and NAT payload mangling.

---

 net/netfilter/nf_conntrack_netlink.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)
net/netfilter/nf_conntrack_netlink.c +10 -0
index ef51e99..016fad5 100644
@@ -1212,6 +1212,16 @@ ctnetlink_create_conntrack(struct nlattr *cda[],
 		}
 	}
 
+#ifdef CONFIG_NF_NAT_NEEDED
+	if (cda[CTA_NAT_SEQ_ADJ_ORIG] || cda[CTA_NAT_SEQ_ADJ_REPLY]) {
+		err = ctnetlink_change_nat_seq_adj(ct, cda);
+		if (err < 0) {
+			rcu_read_unlock();
+			goto err;
+		}
+	}
+#endif
+
 	if (cda[CTA_PROTOINFO]) {
 		err = ctnetlink_change_protoinfo(ct, cda);
 		if (err < 0) {
author maintainer
#1 lore raw

PATCH 2/2 netfilter: ctnetlink: fix echo if not subscribed to any multicast group

This patch fixes echoing if the socket that has sent the request to create/update/delete an entry is not subscribed to any multicast group. With the current code, ctnetlink would not send the echo message via unicast as nfnetlink_send() would be skip.

---

 net/netfilter/nf_conntrack_netlink.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
net/netfilter/nf_conntrack_netlink.c +3 -2
index 2424005..132207f 100644
@@ -535,7 +535,7 @@ static int ctnetlink_conntrack_event(struct notifier_block *this,
 	} else
 		return NOTIFY_DONE;
 
-	if (!nfnetlink_has_listeners(group))
+	if (!item->report && !nfnetlink_has_listeners(group))
 		return NOTIFY_DONE;
 
 	skb = alloc_skb(ctnetlink_calculate_room_size(ct, events), GFP_ATOMIC);
@@ -1609,7 +1609,8 @@ static int ctnetlink_expect_event(struct notifier_block *this,
 	} else
 		return NOTIFY_DONE;
 
-	if (!nfnetlink_has_listeners(NFNLGRP_CONNTRACK_EXP_NEW))
+	if (!item->report &&
+	    !nfnetlink_has_listeners(NFNLGRP_CONNTRACK_EXP_NEW))
 		return NOTIFY_DONE;
 
 	skb = alloc_skb(NLMSG_GOODSIZE, GFP_ATOMIC);
#2 lore raw

Re: [PATCH 2/2] netfilter: ctnetlink: fix echo if not subscribed to any multicast group

Quoted 4 lines · Pablo Neira Ayuso

This patch fixes echoing if the socket that has sent the request to create/update/delete an entry is not subscribed to any multicast group. With the current code, ctnetlink would not send the echo message via unicast as nfnetlink_send() would be skip.

Also applied, thanks.

#3 lore raw
In reply to Pablo Neira Ayuso
Quoted 7 lines · Pablo Neira Ayuso

This patch fixes an inconsistency in the current ctnetlink code since NAT sequence adjustment bit can only be updated but not set in the conntrack entry creation.

This patch is used by conntrackd to successfully recover newly created entries that represent connections with helpers and NAT payload mangling.

Looks good, applied.