Author: tuexen
Date: Fri Jun 19 12:48:22 2015
New Revision: 284596
URL: https://svnweb.freebsd.org/changeset/base/284596

Log:
  When setting the primary address, return an error whenever it fails.
  
  MFC after: 3 days

Modified:
  head/sys/netinet/sctp_usrreq.c

Modified: head/sys/netinet/sctp_usrreq.c
==============================================================================
--- head/sys/netinet/sctp_usrreq.c      Fri Jun 19 09:37:37 2015        
(r284595)
+++ head/sys/netinet/sctp_usrreq.c      Fri Jun 19 12:48:22 2015        
(r284596)
@@ -5678,16 +5678,23 @@ sctp_setopt(struct socket *so, int optna
                        }
 
                        if ((stcb != NULL) && (net != NULL)) {
-                               if ((net != stcb->asoc.primary_destination) &&
-                                   (!(net->dest_state & 
SCTP_ADDR_UNCONFIRMED))) {
-                                       /* Ok we need to set it */
-                                       if (sctp_set_primary_addr(stcb, (struct 
sockaddr *)NULL, net) == 0) {
-                                               if ((stcb->asoc.alternate) &&
-                                                   (!(net->dest_state & 
SCTP_ADDR_PF)) &&
-                                                   (net->dest_state & 
SCTP_ADDR_REACHABLE)) {
-                                                       
sctp_free_remote_addr(stcb->asoc.alternate);
-                                                       stcb->asoc.alternate = 
NULL;
+                               if (net != stcb->asoc.primary_destination) {
+                                       if (!(net->dest_state & 
SCTP_ADDR_UNCONFIRMED)) {
+                                               /* Ok we need to set it */
+                                               if (sctp_set_primary_addr(stcb, 
(struct sockaddr *)NULL, net) == 0) {
+                                                       if 
((stcb->asoc.alternate) &&
+                                                           (!(net->dest_state 
& SCTP_ADDR_PF)) &&
+                                                           (net->dest_state & 
SCTP_ADDR_REACHABLE)) {
+                                                               
sctp_free_remote_addr(stcb->asoc.alternate);
+                                                               
stcb->asoc.alternate = NULL;
+                                                       }
+                                               } else {
+                                                       
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL);
+                                                       error = EINVAL;
                                                }
+                                       } else {
+                                               SCTP_LTRACE_ERR_RET(inp, NULL, 
NULL, SCTP_FROM_SCTP_USRREQ, EINVAL);
+                                               error = EINVAL;
                                        }
                                }
                        } else {
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to