sctp: Allow bindx_del to accept 0 port
authorVlad Yasevich <vladislav.yasevich@hp.com>
Mon, 18 Apr 2011 19:14:47 +0000 (19:14 +0000)
committerDavid S. Miller <davem@davemloft.net>
Wed, 20 Apr 2011 04:45:21 +0000 (21:45 -0700)
We allow 0 port when adding new addresses.  It only
makes sence to allow 0 port when removing addresses.
When removing the currently bound port will be used
when the port in the address is set to 0.

Signed-off-by: Vlad Yasevich <vladislav.yasevich@hp.com>
Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/sctp/socket.c

index 5c9980ae36bba9320296e848ed6dc26f758d98aa..431b8905c570a4bee3fe241ecb4bb6db5fdc9cba 100644 (file)
@@ -658,11 +658,15 @@ static int sctp_bindx_rem(struct sock *sk, struct sockaddr *addrs, int addrcnt)
                        goto err_bindx_rem;
                }
 
-               if (sa_addr->v4.sin_port != htons(bp->port)) {
+               if (sa_addr->v4.sin_port &&
+                   sa_addr->v4.sin_port != htons(bp->port)) {
                        retval = -EINVAL;
                        goto err_bindx_rem;
                }
 
+               if (!sa_addr->v4.sin_port)
+                       sa_addr->v4.sin_port = htons(bp->port);
+
                /* FIXME - There is probably a need to check if sk->sk_saddr and
                 * sk->sk_rcv_addr are currently set to one of the addresses to
                 * be removed. This is something which needs to be looked into