tcp: use IPV6_FLOWLABEL_LEN
Avoid magic numbers when handling the IPv6 flow ID for DSCP and ECN fields and use the named variable instead. Reviewed By: tuexen, #transport Sponsored by: NetApp, Inc. Differential Revision: https://reviews.freebsd.org/D39503
This commit is contained in:
parent
af7624ed31
commit
2169f71277
@ -106,9 +106,9 @@ struct ip6_hdr {
|
||||
#endif
|
||||
#define IPV6_FLOWLABEL_LEN 20
|
||||
|
||||
#define IPV6_TRAFFIC_CLASS(ip6) ((ntohl((ip6)->ip6_flow) >> 20) & 0xff)
|
||||
#define IPV6_DSCP(ip6) ((ntohl((ip6)->ip6_flow) >> 20) & 0xfc)
|
||||
#define IPV6_ECN(ip6) ((ntohl((ip6)->ip6_flow) >> 20) & 0x03)
|
||||
#define IPV6_TRAFFIC_CLASS(ip6) ((ntohl((ip6)->ip6_flow) >> IPV6_FLOWLABEL_LEN) & 0xff)
|
||||
#define IPV6_DSCP(ip6) ((ntohl((ip6)->ip6_flow) >> IPV6_FLOWLABEL_LEN) & 0xfc)
|
||||
#define IPV6_ECN(ip6) ((ntohl((ip6)->ip6_flow) >> IPV6_FLOWLABEL_LEN) & 0x03)
|
||||
|
||||
/*
|
||||
* Extension Headers
|
||||
|
@ -1204,8 +1204,8 @@ tcp_default_output(struct tcpcb *tp)
|
||||
tp->t_flags2 &= ~TF2_ECN_SND_ECE;
|
||||
#ifdef INET6
|
||||
if (isipv6) {
|
||||
ip6->ip6_flow &= ~htonl(IPTOS_ECN_MASK << 20);
|
||||
ip6->ip6_flow |= htonl(ect << 20);
|
||||
ip6->ip6_flow &= ~htonl(IPTOS_ECN_MASK << IPV6_FLOWLABEL_LEN);
|
||||
ip6->ip6_flow |= htonl(ect << IPV6_FLOWLABEL_LEN);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
|
@ -2005,7 +2005,7 @@ tcp_respond(struct tcpcb *tp, void *ipgen, struct tcphdr *th, struct mbuf *m,
|
||||
ulen = tlen - sizeof(struct ip6_hdr);
|
||||
uh->uh_ulen = htons(ulen);
|
||||
}
|
||||
ip6->ip6_flow = htonl(ect << 20);
|
||||
ip6->ip6_flow = htonl(ect << IPV6_FLOWLABEL_LEN);
|
||||
ip6->ip6_vfc = IPV6_VERSION;
|
||||
if (port)
|
||||
ip6->ip6_nxt = IPPROTO_UDP;
|
||||
|
@ -1866,7 +1866,7 @@ syncache_respond(struct syncache *sc, const struct mbuf *m0, int flags)
|
||||
ip6->ip6_nxt = IPPROTO_TCP;
|
||||
th = (struct tcphdr *)(ip6 + 1);
|
||||
}
|
||||
ip6->ip6_flow |= htonl(sc->sc_ip_tos << 20);
|
||||
ip6->ip6_flow |= htonl(sc->sc_ip_tos << IPV6_FLOWLABEL_LEN);
|
||||
}
|
||||
#endif
|
||||
#if defined(INET6) && defined(INET)
|
||||
|
Loading…
Reference in New Issue
Block a user