Skip to contentSkip to conversation

modification of ip_queue in POM format

PATCH In review Eric Leblond 2 participants 2 messages Oct 21, 2003 – Oct 31, 2003 netfilter

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 modification of ip_queue in POM format

Hi,

I attach to this mail modifications of the ip_queue module and of the libipq that permit to mark packet in userspace.

It is a patch against patch-o-matic-20030912.

It has previously been submitted as two "raw" patches.

BR,

Signature · 2 lines
Eric Leblond
Nufw, Now User Filtering Works (http://www.nufw.org)
userspace/ip_queue_vwmark.patch +85 -0
diff -Nru patch-o-matic.orig/userspace/ip_queue_vwmark.patch patch-o-matic/userspace/ip_queue_vwmark.patch
@@ -0,0 +1,85 @@
+diff -uNr linux-2.4.22.orig/include/linux/netfilter_ipv4/ip_queue.h linux-2.4.22/include/linux/netfilter_ipv4/ip_queue.h
+--- linux-2.4.22.orig/include/linux/netfilter_ipv4/ip_queue.h	2000-08-10 21:35:15.000000000 +0200
++++ linux-2.4.22/include/linux/netfilter_ipv4/ip_queue.h	2003-10-21 23:01:36.000000000 +0200
+@@ -47,10 +47,20 @@
+ 	unsigned char payload[0];	/* Optional replacement packet */
+ } ipq_verdict_msg_t;
+ 
++typedef struct ipq_vwmark_msg {
++	unsigned int value;		/* Verdict to hand to netfilter */
++	unsigned long id;		/* Packet ID for this verdict */
++	size_t data_len;		/* Length of replacement data */
++	unsigned char payload[0];	/* Optional replacement packet */
++	unsigned long nfmark;		/* Mark for the Packet */
++} ipq_vwmark_msg_t;
++
++
+ typedef struct ipq_peer_msg {
+ 	union {
+ 		ipq_verdict_msg_t verdict;
+ 		ipq_mode_msg_t mode;
++                ipq_vwmark_msg_t vwmark;
+ 	} msg;
+ } ipq_peer_msg_t;
+ 
+@@ -67,6 +77,7 @@
+ #define IPQM_MODE	(IPQM_BASE + 1)		/* Mode request from peer */
+ #define IPQM_VERDICT	(IPQM_BASE + 2)		/* Verdict from peer */ 
+ #define IPQM_PACKET	(IPQM_BASE + 3)		/* Packet from kernel */
+-#define IPQM_MAX	(IPQM_BASE + 4)
++#define IPQM_VWMARK	(IPQM_BASE + 4)		/* Verdict and mark from peer */
++#define IPQM_MAX	(IPQM_BASE + 5)
+ 
+ #endif /*_IP_QUEUE_H*/
+diff -uNr linux-2.4.22.orig/net/ipv4/netfilter/ip_queue.c linux-2.4.22/net/ipv4/netfilter/ip_queue.c
+--- linux-2.4.22.orig/net/ipv4/netfilter/ip_queue.c	2003-06-13 16:51:39.000000000 +0200
++++ linux-2.4.22/net/ipv4/netfilter/ip_queue.c	2003-10-21 23:01:36.000000000 +0200
+@@ -417,6 +417,33 @@
+ }
+ 
+ static int
++ipq_set_vwmark(struct ipq_vwmark_msg *vmsg, unsigned int len)
++{
++	struct ipq_queue_entry *entry;
++
++	if (vmsg->value > NF_MAX_VERDICT)
++		return -EINVAL;
++
++	entry = ipq_find_dequeue_entry(id_cmp, vmsg->id);
++	if (entry == NULL)
++		return -ENOENT;
++	else {
++		int verdict = vmsg->value;
++		
++		if (vmsg->data_len && vmsg->data_len == len)
++			if (ipq_mangle_ipv4((ipq_verdict_msg_t *)vmsg, entry) < 0)
++				verdict = NF_DROP;
++
++		/* set mark of associated skb */
++		entry->skb->nfmark = vmsg->nfmark;
++		
++		ipq_issue_verdict(entry, verdict);
++		return 0;
++	}
++}
++
++
++static int
+ ipq_receive_peer(struct ipq_peer_msg *pmsg,
+                  unsigned char type, unsigned int len)
+ {
+@@ -438,6 +465,14 @@
+ 			status = ipq_set_verdict(&pmsg->msg.verdict,
+ 			                         len - sizeof(*pmsg));
+ 			break;
++        case IPQM_VWMARK:
++		if (pmsg->msg.verdict.value > NF_MAX_VERDICT)
++			status = -EINVAL;
++		else
++			status = ipq_set_vwmark(&pmsg->msg.vwmark,
++			                         len - sizeof(*pmsg));
++			break;
++
+ 	default:
+ 		status = -EINVAL;
+ 	}
userspace/ip_queue_vwmark.patch.help +14 -0
diff -Nru patch-o-matic.orig/userspace/ip_queue_vwmark.patch.help patch-o-matic/userspace/ip_queue_vwmark.patch.help
@@ -0,0 +1,14 @@
+Author: Eric Leblond <[email protected]>
+Status: It Works For Me.
+
+Adds the possibility to change mark of a packet in userspace.
+The ip_queue module is changed and a new function is added to 
+libipq to decide and change the mark of a packet. 
+
+This is used by the NuFW project (http://www.nufw.org).
+
+***** WARNING ***** 
+This patch breaks compatibility with the preceding version of libipq
+and ip_queue module.
+This patch also patch the userspace directory which means that you
+you have to recompile and reinstall the iptables package after that.
userspace/ip_queue_vwmark.patch.userspace +76 -0

76 lines not on this page · raw message

#1 lore raw
Quoted 7 lines · Eric Leblond

Hi,

I attach to this mail modifications of the ip_queue module and of the libipq that permit to mark packet in userspace.

It is a patch against patch-o-matic-20030912.

thanks, I'll apply it to cvs now.

Quoted 1 line

Eric Leblond

Signature · 5 lines
- Harald Welte <[email protected]>             http://www.netfilter.org/
============================================================================
  "Fragmentation is like classful addressing -- an interesting early
   architectural error that shows how much experimentation was going
   on while IP was being designed."                    -- Paul Vixie