Skip to content

Commit bc7cc59

Browse files
shorman-netronomedavem330
authored andcommitted
openvswitch: update checksum in {push,pop}_mpls
In the case of CHECKSUM_COMPLETE the skb checksum should be updated in {push,pop}_mpls() as they the type in the ethernet header. As suggested by Pravin Shelar. Cc: Pravin Shelar <pshelar@nicira.com> Fixes: 25cd9ba ("openvswitch: Add basic MPLS support to kernel") Signed-off-by: Simon Horman <simon.horman@netronome.com> Acked-by: Pravin B Shelar <pshelar@ovn.org> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 40eb90e commit bc7cc59

1 file changed

Lines changed: 15 additions & 5 deletions

File tree

‎net/openvswitch/actions.c‎

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,23 @@ static bool is_flow_key_valid(const struct sw_flow_key *key)
137137
return !!key->eth.type;
138138
}
139139

140+
static void update_ethertype(struct sk_buff *skb, struct ethhdr *hdr,
141+
__be16 ethertype)
142+
{
143+
if (skb->ip_summed == CHECKSUM_COMPLETE) {
144+
__be16 diff[] = { ~(hdr->h_proto), ethertype };
145+
146+
skb->csum = ~csum_partial((char *)diff, sizeof(diff),
147+
~skb->csum);
148+
}
149+
150+
hdr->h_proto = ethertype;
151+
}
152+
140153
static int push_mpls(struct sk_buff *skb, struct sw_flow_key *key,
141154
const struct ovs_action_push_mpls *mpls)
142155
{
143156
__be32 *new_mpls_lse;
144-
struct ethhdr *hdr;
145157

146158
/* Networking stack do not allow simultaneous Tunnel and MPLS GSO. */
147159
if (skb->encapsulation)
@@ -160,9 +172,7 @@ static int push_mpls(struct sk_buff *skb, struct sw_flow_key *key,
160172

161173
skb_postpush_rcsum(skb, new_mpls_lse, MPLS_HLEN);
162174

163-
hdr = eth_hdr(skb);
164-
hdr->h_proto = mpls->mpls_ethertype;
165-
175+
update_ethertype(skb, eth_hdr(skb), mpls->mpls_ethertype);
166176
if (!skb->inner_protocol)
167177
skb_set_inner_protocol(skb, skb->protocol);
168178
skb->protocol = mpls->mpls_ethertype;
@@ -193,7 +203,7 @@ static int pop_mpls(struct sk_buff *skb, struct sw_flow_key *key,
193203
* field correctly in the presence of VLAN tags.
194204
*/
195205
hdr = (struct ethhdr *)(skb_mpls_header(skb) - ETH_HLEN);
196-
hdr->h_proto = ethertype;
206+
update_ethertype(skb, hdr, ethertype);
197207
if (eth_p_mpls(skb->protocol))
198208
skb->protocol = ethertype;
199209

0 commit comments

Comments
 (0)