Skip to contentSkip to conversation

SO_ORIGINAL_DST for getsockopt() in SCTP

PATCH In review Rafael Laufer 3 participants 5 messages Jul 3, 2009 – Aug 10, 2009

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

PATCH 1/1 SO_ORIGINAL_DST for getsockopt() in SCTP

Hi,

a tiny kernel patch to allow getsockopt() with SO_ORIGINAL_DST to work for SCTP:

net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c 2009-07-02 17:07:09.000000000 -0700 renamed from net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c 2008-12-24 15:26:37.000000000 -0800 +4 -4
diff -rup linux-2.6.28.orig/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c linux-2.6.28/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
@@ -258,11 +258,11 @@ getorigdst(struct sock *sk, int optval,
   tuple.dst.u3.ip = inet->daddr;
   tuple.dst.u.tcp.port = inet->dport;
   tuple.src.l3num = PF_INET;
-   tuple.dst.protonum = IPPROTO_TCP;
+   tuple.dst.protonum = sk->sk_protocol;
 
-   /* We only do TCP at the moment: is there a better way? */
-   if (strcmp(sk->sk_prot->name, "TCP")) {
-       pr_debug("SO_ORIGINAL_DST: Not a TCP socket\n");
+   /* We only do TCP and SCTP at the moment: is there a better way? */
+   if ((sk->sk_protocol != IPPROTO_TCP) && (sk->sk_protocol != IPPROTO_SCTP)) {
+       pr_debug("SO_ORIGINAL_DST: Not a TCP/SCTP socket\n");
       return -ENOPROTOOPT;
   }
 

Rafael

maintainer
#1 lore raw

Thunderbird has severely mangled your patch beyond usability.

Please read Documentation/email-clients.txt in the kernel sources.

#2 lore raw
Quoted 3 lines · David Miller

Thunderbird has severely mangled your patch beyond usability.

Please read Documentation/email-clients.txt in the kernel sources.

Trying again:

net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c +4 -4
diff -rup linux-2.6.28.orig/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c linux-2.6.28/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
@@ -258,11 +258,11 @@ getorigdst(struct sock *sk, int optval, 
 	tuple.dst.u3.ip = inet->daddr;
 	tuple.dst.u.tcp.port = inet->dport;
 	tuple.src.l3num = PF_INET;
-	tuple.dst.protonum = IPPROTO_TCP;
+	tuple.dst.protonum = sk->sk_protocol;
 
-	/* We only do TCP at the moment: is there a better way? */
-	if (strcmp(sk->sk_prot->name, "TCP")) {
-		pr_debug("SO_ORIGINAL_DST: Not a TCP socket\n");
+	/* We only do TCP and SCTP at the moment: is there a better way? */
+	if ((sk->sk_protocol != IPPROTO_TCP) && (sk->sk_protocol != IPPROTO_SCTP)) {
+		pr_debug("SO_ORIGINAL_DST: Not a TCP/SCTP socket\n");
 		return -ENOPROTOOPT;
 	}
 

Rafael

maintainer
#3 lore raw

From: Rafael Laufer <[email protected]>
Date: Thu, 02 Jul 2009 19:26:57 -0700

Quoted 6 lines
Quoted 3 lines · David Miller

Thunderbird has severely mangled your patch beyond usability.

Please read Documentation/email-clients.txt in the kernel sources.

Trying again:

You should make your new posting with full changelog and signoffs so that whoever applies this doesn't have to go searching into the mailing list archives just to hunt that down.

#4 lore raw
In reply to Rafael Laufer
Quoted 16 lines · Rafael Laufer
Quoted 3 lines · David Miller

Thunderbird has severely mangled your patch beyond usability.

Please read Documentation/email-clients.txt in the kernel sources.

Trying again:

diff -rup linux-2.6.28.orig/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c linux-2.6.28/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c

net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c +0 -1
@@ -258,11 +258,11 @@ getorigdst(struct sock *sk, int optval, 
 	tuple.dst.u3.ip = inet->daddr;
 	tuple.dst.u.tcp.port = inet->dport;
 	tuple.src.l3num = PF_INET;
-	tuple.dst.protonum = IPPROTO_TCP;

net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c getorigdst(struct sock *sk, int optval, · line 267

Quoted 10 lines
net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c +4 -3
+	tuple.dst.protonum = sk->sk_protocol;
 
-	/* We only do TCP at the moment: is there a better way? */
-	if (strcmp(sk->sk_prot->name, "TCP")) {
-		pr_debug("SO_ORIGINAL_DST: Not a TCP socket\n");
+	/* We only do TCP and SCTP at the moment: is there a better way? */
+	if ((sk->sk_protocol != IPPROTO_TCP) && (sk->sk_protocol != IPPROTO_SCTP)) {
+		pr_debug("SO_ORIGINAL_DST: Not a TCP/SCTP socket\n");
 		return -ENOPROTOOPT;
 	}

Applied with minor stylistic changes.