runtime: no TCP pseudoheaders needed for directpath
@@ -18,6 +18,19 @@ static void tcp_tx_release_mbuf(struct mbuf *m)
net_tx_release_mbuf(m);
}
+#ifndef DIRECTPATH
+static inline uint16_t tcp_hdr_chksum(uint32_t local_ip, uint32_t remote_ip, uint16_t len)
+{
+ return ipv4_phdr_cksum(IPPROTO_TCP, local_ip, remote_ip,
+ sizeof(struct tcp_hdr) + len);
+}
+#else
+static inline uint16_t tcp_hdr_chksum(uint32_t local_ip, uint32_t remote_ip, uint16_t len)
+{
+ return 0;
+}
+#endif
+
static struct tcp_hdr *
tcp_push_tcphdr(struct mbuf *m, tcpconn_t *c, uint8_t flags, uint16_t l4len)
{
@@ -36,9 +49,7 @@ tcp_push_tcphdr(struct mbuf *m, tcpconn_t *c, uint8_t flags, uint16_t l4len)
tcphdr->flags = flags;
tcphdr->win = hton16(win);
tcphdr->seq = hton32(m->seg_seq);
- tcphdr->sum = ipv4_phdr_cksum(IPPROTO_TCP,
- c->e.laddr.ip, c->e.raddr.ip,
- sizeof(struct tcp_hdr) + l4len);
+ tcphdr->sum = tcp_hdr_chksum(c->e.laddr.ip, c->e.raddr.ip, l4len);
return tcphdr;
}
@@ -71,8 +82,7 @@ int tcp_tx_raw_rst(struct netaddr laddr, struct netaddr raddr, tcp_seq seq)
tcphdr->off = 5;
tcphdr->flags = TCP_RST;
tcphdr->win = hton16(0);
- tcphdr->sum = ipv4_phdr_cksum(IPPROTO_TCP, laddr.ip, raddr.ip,
- sizeof(struct tcp_hdr));
+ tcphdr->sum = tcp_hdr_chksum(laddr.ip, raddr.ip, 0);
/* transmit packet */
ret = net_tx_ip(m, IPPROTO_TCP, raddr.ip);
@@ -112,8 +122,7 @@ int tcp_tx_raw_rst_ack(struct netaddr laddr, struct netaddr raddr,
tcphdr->off = 5;
tcphdr->flags = TCP_RST | TCP_ACK;
tcphdr->win = hton16(0);
- tcphdr->sum = ipv4_phdr_cksum(IPPROTO_TCP, laddr.ip, raddr.ip,
- sizeof(struct tcp_hdr));
+ tcphdr->sum = tcp_hdr_chksum(laddr.ip, raddr.ip, 0);
/* transmit packet */
ret = net_tx_ip(m, IPPROTO_TCP, raddr.ip);
