Skip to contentSkip to conversation

netfilter: CONNMARK: support save the mark of the master connection

PATCH In review Changli Gao 2 participants 3 messages Jan 27, 2011

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 netfilter: CONNMARK: support save the mark of the master connection

In some cases(Policy routing), it is expected that all the sub-connections share the same mark with their master.

---
 include/linux/netfilter/xt_connmark.h |    3 ++-
 net/netfilter/xt_connmark.c           |   15 +++++++++++++++
 2 files changed, 17 insertions(+), 1 deletion(-)
include/linux/netfilter/xt_connmark.h +2 -1
index efc17a8..4b513f8 100644
@@ -15,7 +15,8 @@
 enum {
 	XT_CONNMARK_SET = 0,
 	XT_CONNMARK_SAVE,
-	XT_CONNMARK_RESTORE
+	XT_CONNMARK_RESTORE,
+	XT_CONNMARK_SAVE_MASTER,
 };
 
 struct xt_connmark_tginfo1 {
net/netfilter/xt_connmark.c +15 -0
index 7278145..4207bb6 100644
@@ -69,6 +69,21 @@ connmark_tg(struct sk_buff *skb, const struct xt_action_param *par)
 		          (ct->mark & info->ctmask);
 		skb->mark = newmark;
 		break;
+	case XT_CONNMARK_SAVE_MASTER:
+		if (ct->master) {
+			struct nf_conn *master;
+
+			master = ct->master;
+			while (master->master)
+				master = master->master;
+			newmark = (ct->mark & ~info->ctmask) ^
+				  (master->mark & info->nfmask);
+			if (ct->mark != newmark) {
+				ct->mark = newmark;
+				nf_conntrack_event_cache(IPCT_MARK, ct);
+			}
+		}
+		break;
 	}
 
 	return XT_CONTINUE;
#1 lore raw

Am 27.01.2011 10:38, schrieb Changli Gao:

Quoted 2 lines

In some cases(Policy routing), it is expected that all the sub-connections share the same mark with their master.

We already automatically mark expected connections with the mark of the master. What purpose does your patch serve on top of that?

#2 lore raw
Quoted 8 lines · Patrick McHardy

Am 27.01.2011 10:38, schrieb Changli Gao:

Quoted 2 lines

In some cases(Policy routing), it is expected that all the sub-connections share the same mark with their master.

We already automatically mark expected connections with the mark of the master. What purpose does your patch serve on top of that?

It is done in init_conntrack(), indeed. Sorry for the noise. Thanks.

Signature · 2 lines
Regards,
Changli Gao([email protected])