aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Tuexen <tuexen@FreeBSD.org>2021-04-30 10:27:47 +0000
committerMichael Tuexen <tuexen@FreeBSD.org>2021-04-30 10:31:09 +0000
commiteb79855920ffa33d6c096221eac9cc9a6d7a484b (patch)
treee8aeb0bcfb7863775c94fe0a6e77a004279bfd33
parent388c0cde10293d9a3434e99146bf391aec6878a3 (diff)
downloadsrc-eb79855920ffa33d6c096221eac9cc9a6d7a484b.tar.gz
src-eb79855920ffa33d6c096221eac9cc9a6d7a484b.zip
sctp: fix SCTP_PEER_ADDR_PARAMS socket option
Ignore spp_pathmtu if it is 0, when setting the IPPROTO_SCTP level socket option SCTP_PEER_ADDR_PARAMS as required by RFC 6458. MFC after: 1 week
-rw-r--r--sys/netinet/sctp_usrreq.c72
1 files changed, 40 insertions, 32 deletions
diff --git a/sys/netinet/sctp_usrreq.c b/sys/netinet/sctp_usrreq.c
index 049368c91b56..49cc6f22cc5a 100644
--- a/sys/netinet/sctp_usrreq.c
+++ b/sys/netinet/sctp_usrreq.c
@@ -5327,6 +5327,7 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
return (EINVAL);
}
if ((paddrp->spp_flags & SPP_PMTUD_DISABLE) &&
+ (paddrp->spp_pathmtu > 0) &&
((paddrp->spp_pathmtu < SCTP_SMALLEST_PMTU) ||
(paddrp->spp_pathmtu > SCTP_LARGEST_PMTU))) {
if (stcb)
@@ -5371,23 +5372,25 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
SCTP_FROM_SCTP_USRREQ + SCTP_LOC_11);
}
net->dest_state |= SCTP_ADDR_NO_PMTUD;
- net->mtu = paddrp->spp_pathmtu;
- switch (net->ro._l_addr.sa.sa_family) {
+ if (paddrp->spp_pathmtu > 0) {
+ net->mtu = paddrp->spp_pathmtu;
+ switch (net->ro._l_addr.sa.sa_family) {
#ifdef INET
- case AF_INET:
- net->mtu += SCTP_MIN_V4_OVERHEAD;
- break;
+ case AF_INET:
+ net->mtu += SCTP_MIN_V4_OVERHEAD;
+ break;
#endif
#ifdef INET6
- case AF_INET6:
- net->mtu += SCTP_MIN_OVERHEAD;
- break;
+ case AF_INET6:
+ net->mtu += SCTP_MIN_OVERHEAD;
+ break;
#endif
- default:
- break;
- }
- if (net->mtu < stcb->asoc.smallest_mtu) {
- sctp_pathmtu_adjustment(stcb, net->mtu);
+ default:
+ break;
+ }
+ if (net->mtu < stcb->asoc.smallest_mtu) {
+ sctp_pathmtu_adjustment(stcb, net->mtu);
+ }
}
}
if (paddrp->spp_flags & SPP_PMTUD_ENABLE) {
@@ -5396,7 +5399,7 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
}
net->dest_state &= ~SCTP_ADDR_NO_PMTUD;
}
- if (paddrp->spp_pathmaxrxt) {
+ if (paddrp->spp_pathmaxrxt > 0) {
if (net->dest_state & SCTP_ADDR_PF) {
if (net->error_count > paddrp->spp_pathmaxrxt) {
net->dest_state &= ~SCTP_ADDR_PF;
@@ -5439,7 +5442,7 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
#endif
} else {
/************************ASSOC ONLY -- NO NET SPECIFIC SET ******************/
- if (paddrp->spp_pathmaxrxt != 0) {
+ if (paddrp->spp_pathmaxrxt > 0) {
stcb->asoc.def_net_failure = paddrp->spp_pathmaxrxt;
TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) {
if (net->dest_state & SCTP_ADDR_PF) {
@@ -5471,7 +5474,6 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
net->failure_threshold = paddrp->spp_pathmaxrxt;
}
}
-
if (paddrp->spp_flags & SPP_HB_ENABLE) {
if (paddrp->spp_hbinterval != 0) {
stcb->asoc.heart_beat_delay = paddrp->spp_hbinterval;
@@ -5514,26 +5516,30 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
SCTP_FROM_SCTP_USRREQ + SCTP_LOC_16);
}
net->dest_state |= SCTP_ADDR_NO_PMTUD;
- net->mtu = paddrp->spp_pathmtu;
- switch (net->ro._l_addr.sa.sa_family) {
+ if (paddrp->spp_pathmtu > 0) {
+ net->mtu = paddrp->spp_pathmtu;
+ switch (net->ro._l_addr.sa.sa_family) {
#ifdef INET
- case AF_INET:
- net->mtu += SCTP_MIN_V4_OVERHEAD;
- break;
+ case AF_INET:
+ net->mtu += SCTP_MIN_V4_OVERHEAD;
+ break;
#endif
#ifdef INET6
- case AF_INET6:
- net->mtu += SCTP_MIN_OVERHEAD;
- break;
+ case AF_INET6:
+ net->mtu += SCTP_MIN_OVERHEAD;
+ break;
#endif
- default:
- break;
- }
- if (net->mtu < stcb->asoc.smallest_mtu) {
- sctp_pathmtu_adjustment(stcb, net->mtu);
+ default:
+ break;
+ }
+ if (net->mtu < stcb->asoc.smallest_mtu) {
+ sctp_pathmtu_adjustment(stcb, net->mtu);
+ }
}
}
- stcb->asoc.default_mtu = paddrp->spp_pathmtu;
+ if (paddrp->spp_pathmtu > 0) {
+ stcb->asoc.default_mtu = paddrp->spp_pathmtu;
+ }
sctp_stcb_feature_on(inp, stcb, SCTP_PCB_FLAGS_DO_NOT_PMTUD);
}
if (paddrp->spp_flags & SPP_PMTUD_ENABLE) {
@@ -5580,7 +5586,7 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
* set it with the options on the
* socket
*/
- if (paddrp->spp_pathmaxrxt != 0) {
+ if (paddrp->spp_pathmaxrxt > 0) {
inp->sctp_ep.def_net_failure = paddrp->spp_pathmaxrxt;
}
@@ -5606,7 +5612,9 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
inp->sctp_ep.default_mtu = 0;
sctp_feature_off(inp, SCTP_PCB_FLAGS_DO_NOT_PMTUD);
} else if (paddrp->spp_flags & SPP_PMTUD_DISABLE) {
- inp->sctp_ep.default_mtu = paddrp->spp_pathmtu;
+ if (paddrp->spp_pathmtu > 0) {
+ inp->sctp_ep.default_mtu = paddrp->spp_pathmtu;
+ }
sctp_feature_on(inp, SCTP_PCB_FLAGS_DO_NOT_PMTUD);
}
if (paddrp->spp_flags & SPP_DSCP) {