diff --git a/sys/netinet/sctp_output.c b/sys/netinet/sctp_output.c index 803c30945738..81c9e70d62c1 100644 --- a/sys/netinet/sctp_output.c +++ b/sys/netinet/sctp_output.c @@ -3967,7 +3967,7 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp, ip->ip_v = IPVERSION; ip->ip_hl = (sizeof(struct ip) >> 2); if (net) { - tos_value = net->tos_flowlabel & 0x000000ff; + tos_value = net->dscp; } else { tos_value = inp->ip_inp.inp.inp_ip_tos; } @@ -4204,7 +4204,7 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp, int len; if (net != NULL) { - flowlabel = net->tos_flowlabel; + flowlabel = net->flowlabel; } else { flowlabel = ((struct in6pcb *)inp)->in6p_flowinfo; } diff --git a/sys/netinet/sctp_pcb.c b/sys/netinet/sctp_pcb.c index 728fa7c69745..912e34870a33 100644 --- a/sys/netinet/sctp_pcb.c +++ b/sys/netinet/sctp_pcb.c @@ -4009,20 +4009,13 @@ sctp_add_remote_addr(struct sctp_tcb *stcb, struct sockaddr *newaddr, stcb->asoc.numnets++; *(&net->ref_count) = 1; net->cwr_window_tsn = net->last_cwr_tsn = stcb->asoc.sending_seq - 1; - net->tos_flowlabel = 0; if (SCTP_BASE_SYSCTL(sctp_udp_tunneling_for_client_enable)) { net->port = htons(SCTP_BASE_SYSCTL(sctp_udp_tunneling_port)); } else { net->port = 0; } -#ifdef INET - if (newaddr->sa_family == AF_INET) - net->tos_flowlabel = stcb->asoc.default_tos; -#endif -#ifdef INET6 - if (newaddr->sa_family == AF_INET6) - net->tos_flowlabel = stcb->asoc.default_flowlabel; -#endif + net->dscp = stcb->asoc.default_dscp; + net->flowlabel = stcb->asoc.default_flowlabel; if (sctp_is_feature_on(stcb->sctp_ep, SCTP_PCB_FLAGS_DONOT_HEARTBEAT)) { net->dest_state |= SCTP_ADDR_NOHB; } else { diff --git a/sys/netinet/sctp_structs.h b/sys/netinet/sctp_structs.h index df3898f064d4..362f9cbf991c 100644 --- a/sys/netinet/sctp_structs.h +++ b/sys/netinet/sctp_structs.h @@ -321,7 +321,8 @@ struct sctp_nets { uint32_t fast_recovery_tsn; uint32_t heartbeat_random1; uint32_t heartbeat_random2; - uint32_t tos_flowlabel; + uint32_t flowlabel; + uint8_t dscp; struct timeval start_time; /* time when this net was created */ uint32_t marked_retrans;/* number or DATA chunks marked for timer @@ -1137,7 +1138,7 @@ struct sctp_association { uint8_t last_flags_delivered; uint8_t hb_ect_randombit; uint8_t hb_random_idx; - uint8_t default_tos; + uint8_t default_dscp; uint8_t asconf_del_pending; /* asconf delete last addr pending */ /* diff --git a/sys/netinet/sctp_uio.h b/sys/netinet/sctp_uio.h index d4a0df183f96..37e9b798a991 100644 --- a/sys/netinet/sctp_uio.h +++ b/sys/netinet/sctp_uio.h @@ -505,9 +505,11 @@ struct sctp_paddrparams { uint32_t spp_flags; uint32_t spp_ipv6_flowlabel; uint16_t spp_pathmaxrxt; - uint8_t spp_ipv4_tos; + uint8_t spp_dscp; }; +#define spp_ipv4_tos spp_dscp + #define SPP_HB_ENABLE 0x00000001 #define SPP_HB_DISABLE 0x00000002 #define SPP_HB_DEMAND 0x00000004 @@ -515,7 +517,8 @@ struct sctp_paddrparams { #define SPP_PMTUD_DISABLE 0x00000010 #define SPP_HB_TIME_IS_ZERO 0x00000080 #define SPP_IPV6_FLOWLABEL 0x00000100 -#define SPP_IPV4_TOS 0x00000200 +#define SPP_DSCP 0x00000200 +#define SPP_IPV4_TOS SPP_DSCP struct sctp_paddrthlds { sctp_assoc_t spt_assoc_id; diff --git a/sys/netinet/sctp_usrreq.c b/sys/netinet/sctp_usrreq.c index 275e9a284f65..b6d7c712988d 100644 --- a/sys/netinet/sctp_usrreq.c +++ b/sys/netinet/sctp_usrreq.c @@ -2416,13 +2416,13 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize, } #ifdef INET if (net->ro._l_addr.sin.sin_family == AF_INET) { - paddrp->spp_ipv4_tos = net->tos_flowlabel & 0x000000fc; - paddrp->spp_flags |= SPP_IPV4_TOS; + paddrp->spp_dscp = net->dscp; + paddrp->spp_flags |= SPP_DSCP; } #endif #ifdef INET6 if (net->ro._l_addr.sin6.sin6_family == AF_INET6) { - paddrp->spp_ipv6_flowlabel = net->tos_flowlabel; + paddrp->spp_ipv6_flowlabel = net->flowlabel; paddrp->spp_flags |= SPP_IPV6_FLOWLABEL; } #endif @@ -2436,8 +2436,8 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize, paddrp->spp_pathmaxrxt = stcb->asoc.def_net_failure; paddrp->spp_pathmtu = sctp_get_frag_point(stcb, &stcb->asoc); #ifdef INET - paddrp->spp_ipv4_tos = stcb->asoc.default_tos & 0x000000fc; - paddrp->spp_flags |= SPP_IPV4_TOS; + paddrp->spp_dscp = stcb->asoc.default_dscp & 0x000000fc; + paddrp->spp_flags |= SPP_DSCP; #endif #ifdef INET6 paddrp->spp_ipv6_flowlabel = stcb->asoc.default_flowlabel; @@ -2470,8 +2470,8 @@ sctp_getopt(struct socket *so, int optname, void *optval, size_t *optsize, paddrp->spp_assoc_id = SCTP_FUTURE_ASSOC; /* get inp's default */ #ifdef INET - paddrp->spp_ipv4_tos = inp->ip_inp.inp.inp_ip_tos; - paddrp->spp_flags |= SPP_IPV4_TOS; + paddrp->spp_dscp = inp->ip_inp.inp.inp_ip_tos; + paddrp->spp_flags |= SPP_DSCP; #endif #ifdef INET6 if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) { @@ -4626,16 +4626,16 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, net->failure_threshold = paddrp->spp_pathmaxrxt; } #ifdef INET - if (paddrp->spp_flags & SPP_IPV4_TOS) { + if (paddrp->spp_flags & SPP_DSCP) { if (net->ro._l_addr.sin.sin_family == AF_INET) { - net->tos_flowlabel = paddrp->spp_ipv4_tos & 0x000000fc; + net->dscp = paddrp->spp_dscp & 0xfc; } } #endif #ifdef INET6 if (paddrp->spp_flags & SPP_IPV6_FLOWLABEL) { if (net->ro._l_addr.sin6.sin6_family == AF_INET6) { - net->tos_flowlabel = paddrp->spp_ipv6_flowlabel; + net->flowlabel = paddrp->spp_ipv6_flowlabel & 0x000fffff; } } #endif @@ -4724,27 +4724,18 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, } } } -#ifdef INET - if (paddrp->spp_flags & SPP_IPV4_TOS) { + if (paddrp->spp_flags & SPP_DSCP) { TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) { - if (net->ro._l_addr.sin.sin_family == AF_INET) { - net->tos_flowlabel = paddrp->spp_ipv4_tos & 0x000000fc; - } + net->dscp = paddrp->spp_dscp & 0x000000fc; } - stcb->asoc.default_tos = paddrp->spp_ipv4_tos & 0x000000fc; + stcb->asoc.default_dscp = paddrp->spp_dscp & 0x000000fc; } -#endif -#ifdef INET6 if (paddrp->spp_flags & SPP_IPV6_FLOWLABEL) { TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) { - if (net->ro._l_addr.sin6.sin6_family == AF_INET6) { - net->tos_flowlabel = paddrp->spp_ipv6_flowlabel; - } + net->flowlabel = paddrp->spp_ipv6_flowlabel; } stcb->asoc.default_flowlabel = paddrp->spp_ipv6_flowlabel; } -#endif - } SCTP_TCB_UNLOCK(stcb); } else { diff --git a/sys/netinet/sctputil.c b/sys/netinet/sctputil.c index 9beedbb52ef1..b7336765b97c 100644 --- a/sys/netinet/sctputil.c +++ b/sys/netinet/sctputil.c @@ -924,9 +924,9 @@ sctp_init_asoc(struct sctp_inpcb *m, struct sctp_tcb *stcb, asoc->sctp_frag_point = m->sctp_frag_point; asoc->sctp_features = m->sctp_features; #ifdef INET - asoc->default_tos = m->ip_inp.inp.inp_ip_tos; + asoc->default_dscp = m->ip_inp.inp.inp_ip_tos; #else - asoc->default_tos = 0; + asoc->default_dscp = 0; #endif #ifdef INET6