Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet/tcp_output.c
Show First 20 Lines • Show All 1,148 Lines • ▼ Show 20 Lines | #endif | ||||
m->m_pkthdr.rcvif = (struct ifnet *)0; | m->m_pkthdr.rcvif = (struct ifnet *)0; | ||||
#ifdef MAC | #ifdef MAC | ||||
mac_inpcb_create_mbuf(tp->t_inpcb, m); | mac_inpcb_create_mbuf(tp->t_inpcb, m); | ||||
#endif | #endif | ||||
#ifdef INET6 | #ifdef INET6 | ||||
if (isipv6) { | if (isipv6) { | ||||
ip6 = mtod(m, struct ip6_hdr *); | ip6 = mtod(m, struct ip6_hdr *); | ||||
if (tp->t_port) { | if (tp->t_port) { | ||||
udp = (struct udphdr *)((caddr_t)ip6 + ipoptlen + sizeof(struct ip6_hdr)); | udp = (struct udphdr *)((caddr_t)ip6 + sizeof(struct ip6_hdr)); | ||||
udp->uh_sport = htons(V_tcp_udp_tunneling_port); | udp->uh_sport = htons(V_tcp_udp_tunneling_port); | ||||
udp->uh_dport = tp->t_port; | udp->uh_dport = tp->t_port; | ||||
ulen = hdrlen + len - sizeof(struct ip6_hdr); | ulen = hdrlen + len - sizeof(struct ip6_hdr); | ||||
udp->uh_ulen = htons(ulen); | udp->uh_ulen = htons(ulen); | ||||
th = (struct tcphdr *)(udp + 1); | th = (struct tcphdr *)(udp + 1); | ||||
} else { | } else { | ||||
th = (struct tcphdr *)(ip6 + 1); | th = (struct tcphdr *)(ip6 + 1); | ||||
} | } | ||||
tcpip_fillheaders(tp->t_inpcb, tp->t_port, ip6, th); | tcpip_fillheaders(tp->t_inpcb, tp->t_port, ip6, th); | ||||
markj: This code is duplicated 6 times across the various TCP stacks. Could we lift it into a… | |||||
tuexenAuthorUnsubmitted Done Inline ActionsThis is true for more than this. For RACK/BBR there are common functions, but not so much for the base stack and the optional ones. tuexen: This is true for more than this. For RACK/BBR there are common functions, but not so much for… | |||||
} else | } else | ||||
#endif /* INET6 */ | #endif /* INET6 */ | ||||
{ | { | ||||
ip = mtod(m, struct ip *); | ip = mtod(m, struct ip *); | ||||
#ifdef TCPDEBUG | #ifdef TCPDEBUG | ||||
ipov = (struct ipovly *)ip; | ipov = (struct ipovly *)ip; | ||||
#endif | #endif | ||||
if (tp->t_port) { | if (tp->t_port) { | ||||
udp = (struct udphdr *)((caddr_t)ip + ipoptlen + sizeof(struct ip)); | udp = (struct udphdr *)((caddr_t)ip + sizeof(struct ip)); | ||||
udp->uh_sport = htons(V_tcp_udp_tunneling_port); | udp->uh_sport = htons(V_tcp_udp_tunneling_port); | ||||
udp->uh_dport = tp->t_port; | udp->uh_dport = tp->t_port; | ||||
ulen = hdrlen + len - sizeof(struct ip); | ulen = hdrlen + len - sizeof(struct ip); | ||||
udp->uh_ulen = htons(ulen); | udp->uh_ulen = htons(ulen); | ||||
th = (struct tcphdr *)(udp + 1); | th = (struct tcphdr *)(udp + 1); | ||||
} else | } else | ||||
th = (struct tcphdr *)(ip + 1); | th = (struct tcphdr *)(ip + 1); | ||||
tcpip_fillheaders(tp->t_inpcb, tp->t_port, ip, th); | tcpip_fillheaders(tp->t_inpcb, tp->t_port, ip, th); | ||||
▲ Show 20 Lines • Show All 1,009 Lines • Show Last 20 Lines |
This code is duplicated 6 times across the various TCP stacks. Could we lift it into a subroutine as a follow-up change?