Skip to content

Commit 6b83d28

Browse files
borkmanndavem330
authored andcommitted
net: use skb_postpush_rcsum instead of own implementations
Replace individual implementations with the recently introduced skb_postpush_rcsum() helper. Signed-off-by: Daniel Borkmann <[email protected]> Acked-by: Tom Herbert <[email protected]> Acked-by: Alexei Starovoitov <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 321b4d4 commit 6b83d28

File tree

5 files changed

+7
-20
lines changed

5 files changed

+7
-20
lines changed

net/core/skbuff.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4496,9 +4496,7 @@ int skb_vlan_push(struct sk_buff *skb, __be16 vlan_proto, u16 vlan_tci)
44964496
skb->mac_len += VLAN_HLEN;
44974497
__skb_pull(skb, offset);
44984498

4499-
if (skb->ip_summed == CHECKSUM_COMPLETE)
4500-
skb->csum = csum_add(skb->csum, csum_partial(skb->data
4501-
+ (2 * ETH_ALEN), VLAN_HLEN, 0));
4499+
skb_postpush_rcsum(skb, skb->data + (2 * ETH_ALEN), VLAN_HLEN);
45024500
}
45034501
__vlan_hwaccel_put_tag(skb, vlan_proto, vlan_tci);
45044502
return 0;

net/ipv6/reassembly.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -496,10 +496,8 @@ static int ip6_frag_reasm(struct frag_queue *fq, struct sk_buff *prev,
496496
IP6CB(head)->flags |= IP6SKB_FRAGMENTED;
497497

498498
/* Yes, and fold redundant checksum back. 8) */
499-
if (head->ip_summed == CHECKSUM_COMPLETE)
500-
head->csum = csum_partial(skb_network_header(head),
501-
skb_network_header_len(head),
502-
head->csum);
499+
skb_postpush_rcsum(head, skb_network_header(head),
500+
skb_network_header_len(head));
503501

504502
rcu_read_lock();
505503
IP6_INC_STATS_BH(net, __in6_dev_get(dev), IPSTATS_MIB_REASMOKS);

net/openvswitch/actions.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,7 @@ static int push_mpls(struct sk_buff *skb, struct sw_flow_key *key,
158158
new_mpls_lse = (__be32 *)skb_mpls_header(skb);
159159
*new_mpls_lse = mpls->mpls_lse;
160160

161-
if (skb->ip_summed == CHECKSUM_COMPLETE)
162-
skb->csum = csum_add(skb->csum, csum_partial(new_mpls_lse,
163-
MPLS_HLEN, 0));
161+
skb_postpush_rcsum(skb, new_mpls_lse, MPLS_HLEN);
164162

165163
hdr = eth_hdr(skb);
166164
hdr->h_proto = mpls->mpls_ethertype;
@@ -280,7 +278,7 @@ static int set_eth_addr(struct sk_buff *skb, struct sw_flow_key *flow_key,
280278
ether_addr_copy_masked(eth_hdr(skb)->h_dest, key->eth_dst,
281279
mask->eth_dst);
282280

283-
ovs_skb_postpush_rcsum(skb, eth_hdr(skb), ETH_ALEN * 2);
281+
skb_postpush_rcsum(skb, eth_hdr(skb), ETH_ALEN * 2);
284282

285283
ether_addr_copy(flow_key->eth.src, eth_hdr(skb)->h_source);
286284
ether_addr_copy(flow_key->eth.dst, eth_hdr(skb)->h_dest);
@@ -639,7 +637,7 @@ static int ovs_vport_output(struct net *net, struct sock *sk, struct sk_buff *sk
639637
/* Reconstruct the MAC header. */
640638
skb_push(skb, data->l2_len);
641639
memcpy(skb->data, &data->l2_data, data->l2_len);
642-
ovs_skb_postpush_rcsum(skb, skb->data, data->l2_len);
640+
skb_postpush_rcsum(skb, skb->data, data->l2_len);
643641
skb_reset_mac_header(skb);
644642

645643
ovs_vport_send(vport, skb);

net/openvswitch/vport-netdev.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ static void netdev_port_receive(struct sk_buff *skb)
5858
return;
5959

6060
skb_push(skb, ETH_HLEN);
61-
ovs_skb_postpush_rcsum(skb, skb->data, ETH_HLEN);
61+
skb_postpush_rcsum(skb, skb->data, ETH_HLEN);
6262
ovs_vport_receive(vport, skb, skb_tunnel_info(skb));
6363
return;
6464
error:

net/openvswitch/vport.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -185,13 +185,6 @@ static inline struct vport *vport_from_priv(void *priv)
185185
int ovs_vport_receive(struct vport *, struct sk_buff *,
186186
const struct ip_tunnel_info *);
187187

188-
static inline void ovs_skb_postpush_rcsum(struct sk_buff *skb,
189-
const void *start, unsigned int len)
190-
{
191-
if (skb->ip_summed == CHECKSUM_COMPLETE)
192-
skb->csum = csum_add(skb->csum, csum_partial(start, len, 0));
193-
}
194-
195188
static inline const char *ovs_vport_name(struct vport *vport)
196189
{
197190
return vport->dev->name;

0 commit comments

Comments
 (0)