Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft: xdp: checksum optimization #22

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/bpf/gtp_fwd.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,15 +202,15 @@ gtpu_ipencap(struct parse_pkt *pkt, struct gtp_iptnl_rule *iptnl_rule)
static __always_inline void
gtpu_xlat_iph(struct iphdr *iph, __be32 daddr)
{
__u32 csum = 0;
__u32 csum;

/* Phase 1 : rewrite IP header */
iph->saddr = iph->daddr;
iph->daddr = daddr;
--iph->ttl;
iph->check = 0;
ipv4_csum(iph, sizeof(struct iphdr), &csum);
iph->check = csum;
/* avoid doing ipv4_csum(iph, sizeof(struct iphdr), &csum); */
csum = iph->check + 0x100; /* RFC 1141: incremet checksum high byte */
iph->check = csum + (csum >> 16); /* add carry */
}

static __always_inline void
Expand Down