Skip to content

Commit 67fa034

Browse files
jessegrossdavem330
authored andcommitted
openvswitch: Add support for matching on OAM packets.
Some tunnel formats have mechanisms for indicating that packets are OAM frames that should be handled specially (either as high priority or not forwarded beyond an endpoint). This provides support for allowing those types of packets to be matched. Signed-off-by: Jesse Gross <jesse@nicira.com> Signed-off-by: Andy Zhou <azhou@nicira.com> Acked-by: Pravin B Shelar <pshelar@nicira.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 0714812 commit 67fa034

3 files changed

Lines changed: 14 additions & 5 deletions

File tree

‎include/uapi/linux/openvswitch.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@ enum ovs_tunnel_key_attr {
309309
OVS_TUNNEL_KEY_ATTR_TTL, /* u8 Tunnel IP TTL. */
310310
OVS_TUNNEL_KEY_ATTR_DONT_FRAGMENT, /* No argument, set DF. */
311311
OVS_TUNNEL_KEY_ATTR_CSUM, /* No argument. CSUM packet. */
312+
OVS_TUNNEL_KEY_ATTR_OAM, /* No argument. OAM frame. */
312313
__OVS_TUNNEL_KEY_ATTR_MAX
313314
};
314315

‎net/openvswitch/datapath.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,7 @@ static size_t key_attr_size(void)
369369
+ nla_total_size(1) /* OVS_TUNNEL_KEY_ATTR_TTL */
370370
+ nla_total_size(0) /* OVS_TUNNEL_KEY_ATTR_DONT_FRAGMENT */
371371
+ nla_total_size(0) /* OVS_TUNNEL_KEY_ATTR_CSUM */
372+
+ nla_total_size(0) /* OVS_TUNNEL_KEY_ATTR_OAM */
372373
+ nla_total_size(4) /* OVS_KEY_ATTR_IN_PORT */
373374
+ nla_total_size(4) /* OVS_KEY_ATTR_SKB_MARK */
374375
+ nla_total_size(12) /* OVS_KEY_ATTR_ETHERNET */

‎net/openvswitch/flow_netlink.c‎

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@ static int ipv4_tun_from_nlattr(const struct nlattr *attr,
346346
[OVS_TUNNEL_KEY_ATTR_TTL] = 1,
347347
[OVS_TUNNEL_KEY_ATTR_DONT_FRAGMENT] = 0,
348348
[OVS_TUNNEL_KEY_ATTR_CSUM] = 0,
349+
[OVS_TUNNEL_KEY_ATTR_OAM] = 0,
349350
};
350351

351352
if (type > OVS_TUNNEL_KEY_ATTR_MAX) {
@@ -390,6 +391,9 @@ static int ipv4_tun_from_nlattr(const struct nlattr *attr,
390391
case OVS_TUNNEL_KEY_ATTR_CSUM:
391392
tun_flags |= TUNNEL_CSUM;
392393
break;
394+
case OVS_TUNNEL_KEY_ATTR_OAM:
395+
tun_flags |= TUNNEL_OAM;
396+
break;
393397
default:
394398
return -EINVAL;
395399
}
@@ -431,21 +435,24 @@ static int ipv4_tun_to_nlattr(struct sk_buff *skb,
431435
nla_put_be64(skb, OVS_TUNNEL_KEY_ATTR_ID, output->tun_id))
432436
return -EMSGSIZE;
433437
if (output->ipv4_src &&
434-
nla_put_be32(skb, OVS_TUNNEL_KEY_ATTR_IPV4_SRC, output->ipv4_src))
438+
nla_put_be32(skb, OVS_TUNNEL_KEY_ATTR_IPV4_SRC, output->ipv4_src))
435439
return -EMSGSIZE;
436440
if (output->ipv4_dst &&
437-
nla_put_be32(skb, OVS_TUNNEL_KEY_ATTR_IPV4_DST, output->ipv4_dst))
441+
nla_put_be32(skb, OVS_TUNNEL_KEY_ATTR_IPV4_DST, output->ipv4_dst))
438442
return -EMSGSIZE;
439443
if (output->ipv4_tos &&
440-
nla_put_u8(skb, OVS_TUNNEL_KEY_ATTR_TOS, output->ipv4_tos))
444+
nla_put_u8(skb, OVS_TUNNEL_KEY_ATTR_TOS, output->ipv4_tos))
441445
return -EMSGSIZE;
442446
if (nla_put_u8(skb, OVS_TUNNEL_KEY_ATTR_TTL, output->ipv4_ttl))
443447
return -EMSGSIZE;
444448
if ((output->tun_flags & TUNNEL_DONT_FRAGMENT) &&
445-
nla_put_flag(skb, OVS_TUNNEL_KEY_ATTR_DONT_FRAGMENT))
449+
nla_put_flag(skb, OVS_TUNNEL_KEY_ATTR_DONT_FRAGMENT))
446450
return -EMSGSIZE;
447451
if ((output->tun_flags & TUNNEL_CSUM) &&
448-
nla_put_flag(skb, OVS_TUNNEL_KEY_ATTR_CSUM))
452+
nla_put_flag(skb, OVS_TUNNEL_KEY_ATTR_CSUM))
453+
return -EMSGSIZE;
454+
if ((output->tun_flags & TUNNEL_OAM) &&
455+
nla_put_flag(skb, OVS_TUNNEL_KEY_ATTR_OAM))
449456
return -EMSGSIZE;
450457

451458
nla_nest_end(skb, nla);

0 commit comments

Comments
 (0)