Skip to content

Commit

Permalink
Restrict addresses when adding them to the endpoint.
Browse files Browse the repository at this point in the history
Don't allow setting the peer primary if the address
is restricted and not pending.
This is related to #57
  • Loading branch information
tuexen committed Mar 28, 2016
1 parent a18a569 commit d75dc0c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion usrsctplib/netinet/sctp_pcb.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

#ifdef __FreeBSD__
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: head/sys/netinet/sctp_pcb.c 295805 2016-02-19 11:25:18Z tuexen $");
__FBSDID("$FreeBSD: head/sys/netinet/sctp_pcb.c 297361 2016-03-28 19:31:10Z tuexen $");
#endif

#include <netinet/sctp_os.h>
Expand Down Expand Up @@ -6173,6 +6173,7 @@ void
sctp_add_local_addr_ep(struct sctp_inpcb *inp, struct sctp_ifa *ifa, uint32_t action)
{
struct sctp_laddr *laddr;
struct sctp_tcb *stcb;
int fnd, error = 0;

fnd = 0;
Expand Down Expand Up @@ -6231,6 +6232,9 @@ sctp_add_local_addr_ep(struct sctp_inpcb *inp, struct sctp_ifa *ifa, uint32_t ac
default:
break;
}
LIST_FOREACH(stcb, &inp->sctp_asoc_list, sctp_tcblist) {
sctp_add_local_addr_restricted(stcb, ifa);
}
}
return;
}
Expand Down
6 changes: 5 additions & 1 deletion usrsctplib/netinet/sctp_usrreq.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

#ifdef __FreeBSD__
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: head/sys/netinet/sctp_usrreq.c 297312 2016-03-27 10:04:25Z tuexen $");
__FBSDID("$FreeBSD: head/sys/netinet/sctp_usrreq.c 297362 2016-03-28 19:32:13Z tuexen $");
#endif

#include <netinet/sctp_os.h>
Expand Down Expand Up @@ -6624,6 +6624,10 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
__func__);
continue;
}
if ((sctp_is_addr_restricted(stcb, laddr->ifa)) &&
(!sctp_is_addr_pending(stcb, laddr->ifa))) {
continue;
}
if (laddr->ifa == ifa) {
found = 1;
break;
Expand Down

0 comments on commit d75dc0c

Please sign in to comment.