Skip to content

Commit fa642f0

Browse files
YiHungWeidavem330
authored andcommitted
openvswitch: Derive IP protocol number for IPv6 later frags
Currently, OVS only parses the IP protocol number for the first IPv6 fragment, but sets the IP protocol number for the later fragments to be NEXTHDF_FRAGMENT. This patch tries to derive the IP protocol number for the IPV6 later frags so that we can match that. Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com> Acked-by: Pravin B Shelar <pshelar@ovn.org> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent ddc4d23 commit fa642f0

1 file changed

Lines changed: 9 additions & 13 deletions

File tree

‎net/openvswitch/flow.c‎

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -254,21 +254,18 @@ static bool icmphdr_ok(struct sk_buff *skb)
254254

255255
static int parse_ipv6hdr(struct sk_buff *skb, struct sw_flow_key *key)
256256
{
257+
unsigned short frag_off;
258+
unsigned int payload_ofs = 0;
257259
unsigned int nh_ofs = skb_network_offset(skb);
258260
unsigned int nh_len;
259-
int payload_ofs;
260261
struct ipv6hdr *nh;
261-
uint8_t nexthdr;
262-
__be16 frag_off;
263-
int err;
262+
int err, nexthdr, flags = 0;
264263

265264
err = check_header(skb, nh_ofs + sizeof(*nh));
266265
if (unlikely(err))
267266
return err;
268267

269268
nh = ipv6_hdr(skb);
270-
nexthdr = nh->nexthdr;
271-
payload_ofs = (u8 *)(nh + 1) - skb->data;
272269

273270
key->ip.proto = NEXTHDR_NONE;
274271
key->ip.tos = ipv6_get_dsfield(nh);
@@ -277,22 +274,21 @@ static int parse_ipv6hdr(struct sk_buff *skb, struct sw_flow_key *key)
277274
key->ipv6.addr.src = nh->saddr;
278275
key->ipv6.addr.dst = nh->daddr;
279276

280-
payload_ofs = ipv6_skip_exthdr(skb, payload_ofs, &nexthdr, &frag_off);
281-
282-
if (frag_off) {
283-
if (frag_off & htons(~0x7))
277+
nexthdr = ipv6_find_hdr(skb, &payload_ofs, -1, &frag_off, &flags);
278+
if (flags & IP6_FH_F_FRAG) {
279+
if (frag_off)
284280
key->ip.frag = OVS_FRAG_TYPE_LATER;
285281
else
286282
key->ip.frag = OVS_FRAG_TYPE_FIRST;
287283
} else {
288284
key->ip.frag = OVS_FRAG_TYPE_NONE;
289285
}
290286

291-
/* Delayed handling of error in ipv6_skip_exthdr() as it
292-
* always sets frag_off to a valid value which may be
287+
/* Delayed handling of error in ipv6_find_hdr() as it
288+
* always sets flags and frag_off to a valid value which may be
293289
* used to set key->ip.frag above.
294290
*/
295-
if (unlikely(payload_ofs < 0))
291+
if (unlikely(nexthdr < 0))
296292
return -EPROTO;
297293

298294
nh_len = payload_ofs - nh_ofs;

0 commit comments

Comments
 (0)