Skip to content

Commit b34df5e

Browse files
Pravin B Shelarjessegross
authored andcommitted
openvswitch: make skb->csum consistent with rest of networking stack.
Following patch keeps skb->csum correct across ovs. Signed-off-by: Pravin B Shelar <pshelar@nicira.com> Signed-off-by: Jesse Gross <jesse@nicira.com>
1 parent 45bfa52 commit b34df5e

5 files changed

Lines changed: 17 additions & 0 deletions

File tree

‎net/openvswitch/actions.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,13 @@ static int set_eth_addr(struct sk_buff *skb,
130130
if (unlikely(err))
131131
return err;
132132

133+
skb_postpull_rcsum(skb, eth_hdr(skb), ETH_ALEN * 2);
134+
133135
memcpy(eth_hdr(skb)->h_source, eth_key->eth_src, ETH_ALEN);
134136
memcpy(eth_hdr(skb)->h_dest, eth_key->eth_dst, ETH_ALEN);
135137

138+
ovs_skb_postpush_rcsum(skb, eth_hdr(skb), ETH_ALEN * 2);
139+
136140
return 0;
137141
}
138142

‎net/openvswitch/flow.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,9 @@ int ovs_flow_extract(struct sk_buff *skb, u16 in_port, struct sw_flow_key *key,
618618
memcpy(key->eth.dst, eth->h_dest, ETH_ALEN);
619619

620620
__skb_pull(skb, 2 * ETH_ALEN);
621+
/* We are going to push all headers that we pull, so no need to
622+
* update skb->csum here.
623+
*/
621624

622625
if (vlan_tx_tag_present(skb))
623626
key->eth.tci = htons(skb->vlan_tci);

‎net/openvswitch/vport-internal_dev.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ static int internal_dev_recv(struct vport *vport, struct sk_buff *skb)
221221
skb->dev = netdev;
222222
skb->pkt_type = PACKET_HOST;
223223
skb->protocol = eth_type_trans(skb, netdev);
224+
skb_postpull_rcsum(skb, eth_hdr(skb), ETH_HLEN);
224225

225226
netif_rx(skb);
226227

‎net/openvswitch/vport-netdev.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ static void netdev_port_receive(struct vport *vport, struct sk_buff *skb)
4949
return;
5050

5151
skb_push(skb, ETH_HLEN);
52+
ovs_skb_postpush_rcsum(skb, skb->data, ETH_HLEN);
53+
5254
ovs_vport_receive(vport, skb);
5355
return;
5456

‎net/openvswitch/vport.h‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,4 +192,11 @@ void ovs_vport_record_error(struct vport *, enum vport_err_type err_type);
192192
extern const struct vport_ops ovs_netdev_vport_ops;
193193
extern const struct vport_ops ovs_internal_vport_ops;
194194

195+
static inline void ovs_skb_postpush_rcsum(struct sk_buff *skb,
196+
const void *start, unsigned int len)
197+
{
198+
if (skb->ip_summed == CHECKSUM_COMPLETE)
199+
skb->csum = csum_add(skb->csum, csum_partial(start, len, 0));
200+
}
201+
195202
#endif /* vport.h */

0 commit comments

Comments
 (0)