Skip to content

Commit

Permalink
datapath: compat: Use checksum offload for outer header.
Browse files Browse the repository at this point in the history
Following patch simplifies UDP-checksum routine by unconditionally
using checksum offload for non GSO packets. We might get some
performance improvement due to code simplification.

Signed-off-by: Pravin B Shelar <[email protected]>
Acked-by: Jesse Gross <[email protected]>
  • Loading branch information
pshelar committed Aug 3, 2016
1 parent b416d16 commit aad4ff6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 32 deletions.
17 changes: 1 addition & 16 deletions datapath/linux/compat/udp.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,13 @@ void rpl_udp_set_csum(bool nocheck, struct sk_buff *skb,
uh->check = 0;
else if (skb_is_gso(skb))
uh->check = ~udp_v4_check(len, saddr, daddr, 0);
else if (skb_dst(skb) && skb_dst(skb)->dev &&
(skb_dst(skb)->dev->features & NETIF_F_V4_CSUM)) {

else {
BUG_ON(skb->ip_summed == CHECKSUM_PARTIAL);

skb->ip_summed = CHECKSUM_PARTIAL;
skb->csum_start = skb_transport_header(skb) - skb->head;
skb->csum_offset = offsetof(struct udphdr, check);
uh->check = ~udp_v4_check(len, saddr, daddr, 0);
} else {
int l4_offset = skb_transport_offset(skb);
__wsum csum;

BUG_ON(skb->ip_summed == CHECKSUM_PARTIAL);

uh->check = 0;
csum = skb_checksum(skb, l4_offset, len, 0);
uh->check = udp_v4_check(len, saddr, daddr, csum);
if (uh->check == 0)
uh->check = CSUM_MANGLED_0;

skb->ip_summed = CHECKSUM_UNNECESSARY;
}
}
EXPORT_SYMBOL_GPL(rpl_udp_set_csum);
Expand Down
17 changes: 1 addition & 16 deletions datapath/linux/compat/udp_tunnel.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,28 +193,13 @@ static void udp6_set_csum(bool nocheck, struct sk_buff *skb,
uh->check = 0;
else if (skb_is_gso(skb))
uh->check = ~udp_v6_check(len, saddr, daddr, 0);
else if (skb_dst(skb) && skb_dst(skb)->dev &&
(skb_dst(skb)->dev->features & NETIF_F_IPV6_CSUM)) {

else {
BUG_ON(skb->ip_summed == CHECKSUM_PARTIAL);

skb->ip_summed = CHECKSUM_PARTIAL;
skb->csum_start = skb_transport_header(skb) - skb->head;
skb->csum_offset = offsetof(struct udphdr, check);
uh->check = ~udp_v6_check(len, saddr, daddr, 0);
} else {
int l4_offset = skb_transport_offset(skb);
__wsum csum;

BUG_ON(skb->ip_summed == CHECKSUM_PARTIAL);

uh->check = 0;
csum = skb_checksum(skb, l4_offset, len, 0);
uh->check = udp_v6_check(len, saddr, daddr, csum);
if (uh->check == 0)
uh->check = CSUM_MANGLED_0;

skb->ip_summed = CHECKSUM_UNNECESSARY;
}
}

Expand Down

0 comments on commit aad4ff6

Please sign in to comment.