]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
[SCTP]: Correctly set IP id for SCTP traffic
authorVlad Yasevich <vladislav.yasevich@hp.com>
Tue, 31 Oct 2006 02:54:32 +0000 (18:54 -0800)
committerDavid S. Miller <davem@davemloft.net>
Tue, 31 Oct 2006 02:54:32 +0000 (18:54 -0800)
Make SCTP 1-1 style and peeled-off associations behave like TCP when
setting IP id. In both cases, we set the inet_sk(sk)->daddr and initialize
inet_sk(sk)->id to a random value.

Signed-off-by: Vlad Yasevich <vladislav.yasevich@hp.com>
Signed-off-by: Sridhar Samudrala <sri@us.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/sctp/protocol.c
net/sctp/socket.c

index fac7674438a4c00b3e28e8a33b0565e6a0d74637..5b4f82fd98f834456ae308cd4ee3426ba29409e8 100644 (file)
@@ -591,7 +591,7 @@ static struct sock *sctp_v4_create_accept_sk(struct sock *sk,
        newinet->dport = htons(asoc->peer.port);
        newinet->daddr = asoc->peer.primary_addr.v4.sin_addr.s_addr;
        newinet->pmtudisc = inet->pmtudisc;
-       newinet->id = 0;
+       newinet->id = asoc->next_tsn ^ jiffies;
 
        newinet->uc_ttl = -1;
        newinet->mc_loop = 1;
index 9f34dec6ff8ec0cd70acfb72e594f016c60a36a8..935bc9187fd81335cd2b3bbf5c5e78fec5b05d73 100644 (file)
@@ -3372,6 +3372,7 @@ SCTP_STATIC int sctp_do_peeloff(struct sctp_association *asoc,
 {
        struct sock *sk = asoc->base.sk;
        struct socket *sock;
+       struct inet_sock *inetsk;
        int err = 0;
 
        /* An association cannot be branched off from an already peeled-off
@@ -3389,6 +3390,14 @@ SCTP_STATIC int sctp_do_peeloff(struct sctp_association *asoc,
         * asoc to the newsk.
         */
        sctp_sock_migrate(sk, sock->sk, asoc, SCTP_SOCKET_UDP_HIGH_BANDWIDTH);
+
+       /* Make peeled-off sockets more like 1-1 accepted sockets.
+        * Set the daddr and initialize id to something more random
+        */
+       inetsk = inet_sk(sock->sk);
+       inetsk->daddr = asoc->peer.primary_addr.v4.sin_addr.s_addr;
+       inetsk->id = asoc->next_tsn ^ jiffies;
+
        *sockp = sock;
 
        return err;