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.6 tree, thanks.

Author: Harald Welte <[email protected]>

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
net/ipv4/netfilter/ip_conntrack_core.c +8 -5
@@ -1275,11 +1275,14 @@
 {
 	struct inet_opt *inet = inet_sk(sk);
 	struct ip_conntrack_tuple_hash *h;
-	struct ip_conntrack_tuple tuple = { { inet->rcv_saddr,
-						{ .tcp = { inet->sport } } },
-					    { inet->daddr,
-						{ .tcp = { inet->dport } },
-					      IPPROTO_TCP } };
+	struct ip_conntrack_tuple tuple;
+	
+	IP_CT_TUPLE_U_BLANK(&tuple);
+	tuple.src.ip = inet->rcv_saddr;
+	tuple.src.u.tcp.port = inet->sport;
+	tuple.dst.ip = inet->daddr;
+	tuple.dst.u.tcp.port = inet->dport;
+	tuple.dst.protonum = IPPROTO_TCP;
 
 	/* We only do TCP at the moment: is there a better way? */
 	if (strcmp(sk->sk_prot->name, "TCP")) {
include/linux/netfilter_ipv4/ip_conntrack_tuple.h renamed from include/linux/netfilter_ipv4/ip_conntrack_tuple.h.orig +8 -0
@@ -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,
#1 lore raw
Quoted 1 line · On Thu, 2 Oct 2003 18:39:55 +0200 Harald Welte <[email protected]> wrote:

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

Applied, thanks.