Skip to contentSkip to conversation

fix SO_ORIGINAL_DST gestsockopt()

PATCH Applied Harald Welte 2 participants 2 messages Oct 2, 2003 – Oct 3, 2003

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

PATCH 1/1 fix SO_ORIGINAL_DST gestsockopt()

Hi Davem!

Please apply the following patch to your 2.4 tree, thanks.

Author: Harald Welte <[email protected]>
Status: Submitted at 2.4.23-preX time

This patch fixes the SO_ORIGINAL_DST sockopt() call, which was broken by endianness fixes that went in 2.4.22.

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
include/linux/netfilter_ipv4/ip_conntrack_tuple.h +8 -0
diff -Nru --exclude .depend --exclude '*.o' --exclude '*.ko' --exclude '*.ver' --exclude '.*.flags' --exclude '*.orig' --exclude '*.rej' --exclude '*.cmd' --exclude '*.mod.c' --exclude '*~' linux-2.4.22-plain/include/linux/netfilter_ipv4/ip_conntrack_tuple.h linux-2.4.22-getorig/include/linux/netfilter_ipv4/ip_conntrack_tuple.h
@@ -62,6 +62,14 @@
 	} dst;
 };
 
+/* This is optimized opposed to a memset of the whole structure.  Everything we
+ * really care about is the  source/destination unions */
+#define IP_CT_TUPLE_U_BLANK(tuple) 				\
+	do {							\
+		(tuple)->src.u.all = 0;				\
+		(tuple)->dst.u.all = 0;				\
+	} while (0)
+
 enum ip_conntrack_dir
 {
 	IP_CT_DIR_ORIGINAL,
net/ipv4/netfilter/ip_conntrack_core.c +8 -3
diff -Nru --exclude .depend --exclude '*.o' --exclude '*.ko' --exclude '*.ver' --exclude '.*.flags' --exclude '*.orig' --exclude '*.rej' --exclude '*.cmd' --exclude '*.mod.c' --exclude '*~' linux-2.4.22-plain/net/ipv4/netfilter/ip_conntrack_core.c linux-2.4.22-getorig/net/ipv4/netfilter/ip_conntrack_core.c
@@ -1303,9 +1303,14 @@
 getorigdst(struct sock *sk, int optval, void *user, int *len)
 {
 	struct ip_conntrack_tuple_hash *h;
-	struct ip_conntrack_tuple tuple = { { sk->rcv_saddr, { .tcp = { sk->sport } } },
-					    { sk->daddr, { .tcp = { sk->dport } },
-					      IPPROTO_TCP } };
+	struct ip_conntrack_tuple tuple;
+
+	IP_CT_TUPLE_U_BLANK(&tuple);
+	tuple.src.ip = sk->rcv_saddr;
+	tuple.src.u.tcp.port = sk->sport;
+	tuple.dst.ip = sk->daddr;
+	tuple.dst.u.tcp.port = sk->dport;
+	tuple.dst.protonum = IPPROTO_TCP;
 
 	/* We only do TCP at the moment: is there a better way? */
 	if (strcmp(sk->prot->name, "TCP") != 0) {
#1 lore raw
Quoted 1 line · On Thu, 2 Oct 2003 18:36:17 +0200 Harald Welte <[email protected]> wrote:

Please apply the following patch to your 2.4 tree, thanks.

Applied, thanks.