Skip to content

Commit

Permalink
tunnel: Add support for matching on OAM packets.
Browse files Browse the repository at this point in the history
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 <[email protected]>
Acked-by: Thomas Graf <[email protected]>
Acked-by: Pravin B Shelar <[email protected]>
  • Loading branch information
jessegross committed Jun 20, 2014
1 parent f0cd669 commit 9487259
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 2 deletions.
1 change: 1 addition & 0 deletions datapath/datapath.c
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ static size_t key_attr_size(void)
+ nla_total_size(1) /* OVS_TUNNEL_KEY_ATTR_TTL */
+ nla_total_size(0) /* OVS_TUNNEL_KEY_ATTR_DONT_FRAGMENT */
+ nla_total_size(0) /* OVS_TUNNEL_KEY_ATTR_CSUM */
+ nla_total_size(0) /* OVS_TUNNEL_KEY_ATTR_OAM */
+ nla_total_size(4) /* OVS_KEY_ATTR_IN_PORT */
+ nla_total_size(4) /* OVS_KEY_ATTR_SKB_MARK */
+ nla_total_size(4) /* OVS_KEY_ATTR_DP_HASH */
Expand Down
7 changes: 7 additions & 0 deletions datapath/flow_netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ static int ipv4_tun_from_nlattr(const struct nlattr *attr,
[OVS_TUNNEL_KEY_ATTR_TTL] = 1,
[OVS_TUNNEL_KEY_ATTR_DONT_FRAGMENT] = 0,
[OVS_TUNNEL_KEY_ATTR_CSUM] = 0,
[OVS_TUNNEL_KEY_ATTR_OAM] = 0,
};

if (type > OVS_TUNNEL_KEY_ATTR_MAX) {
Expand Down Expand Up @@ -391,6 +392,9 @@ static int ipv4_tun_from_nlattr(const struct nlattr *attr,
case OVS_TUNNEL_KEY_ATTR_CSUM:
tun_flags |= TUNNEL_CSUM;
break;
case OVS_TUNNEL_KEY_ATTR_OAM:
tun_flags |= TUNNEL_OAM;
break;
default:
return -EINVAL;
}
Expand Down Expand Up @@ -448,6 +452,9 @@ static int ipv4_tun_to_nlattr(struct sk_buff *skb,
if ((output->tun_flags & TUNNEL_CSUM) &&
nla_put_flag(skb, OVS_TUNNEL_KEY_ATTR_CSUM))
return -EMSGSIZE;
if ((output->tun_flags & TUNNEL_OAM) &&
nla_put_flag(skb, OVS_TUNNEL_KEY_ATTR_OAM))
return -EMSGSIZE;

nla_nest_end(skb, nla);
return 0;
Expand Down
4 changes: 4 additions & 0 deletions datapath/linux/compat/include/net/ip_tunnels.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,8 @@ int iptunnel_xmit(struct rtable *rt,
int iptunnel_pull_header(struct sk_buff *skb, int hdr_len, __be16 inner_proto);

#endif

/* Not yet upstream */
#define TUNNEL_OAM __cpu_to_be16(0x0200)

#endif /* __NET_IP_TUNNELS_H */
1 change: 1 addition & 0 deletions include/linux/openvswitch.h
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ enum ovs_tunnel_key_attr {
OVS_TUNNEL_KEY_ATTR_TTL, /* u8 Tunnel IP TTL. */
OVS_TUNNEL_KEY_ATTR_DONT_FRAGMENT, /* No argument, set DF. */
OVS_TUNNEL_KEY_ATTR_CSUM, /* No argument. CSUM packet. */
OVS_TUNNEL_KEY_ATTR_OAM, /* No argument, OAM frame. */
__OVS_TUNNEL_KEY_ATTR_MAX
};

Expand Down
2 changes: 2 additions & 0 deletions lib/flow.c
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,8 @@ flow_tun_flag_to_string(uint32_t flags)
return "csum";
case FLOW_TNL_F_KEY:
return "key";
case FLOW_TNL_F_OAM:
return "oam";
default:
return NULL;
}
Expand Down
1 change: 1 addition & 0 deletions lib/flow.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ BUILD_ASSERT_DECL(FLOW_NW_FRAG_LATER == NX_IP_FRAG_LATER);
#define FLOW_TNL_F_DONT_FRAGMENT (1 << 0)
#define FLOW_TNL_F_CSUM (1 << 1)
#define FLOW_TNL_F_KEY (1 << 2)
#define FLOW_TNL_F_OAM (1 << 3)

const char *flow_tun_flag_to_string(uint32_t flags);

Expand Down
10 changes: 9 additions & 1 deletion lib/odp-util.c
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,7 @@ tunnel_key_attr_len(int type)
case OVS_TUNNEL_KEY_ATTR_TTL: return 1;
case OVS_TUNNEL_KEY_ATTR_DONT_FRAGMENT: return 0;
case OVS_TUNNEL_KEY_ATTR_CSUM: return 0;
case OVS_TUNNEL_KEY_ATTR_OAM: return 0;
case __OVS_TUNNEL_KEY_ATTR_MAX:
return -1;
}
Expand Down Expand Up @@ -879,6 +880,9 @@ odp_tun_key_from_attr(const struct nlattr *attr, struct flow_tnl *tun)
case OVS_TUNNEL_KEY_ATTR_CSUM:
tun->flags |= FLOW_TNL_F_CSUM;
break;
case OVS_TUNNEL_KEY_ATTR_OAM:
tun->flags |= FLOW_TNL_F_OAM;
break;
default:
/* Allow this to show up as unexpected, if there are unknown
* tunnel attribute, eventually resulting in ODP_FIT_TOO_MUCH. */
Expand Down Expand Up @@ -923,6 +927,9 @@ tun_key_to_attr(struct ofpbuf *a, const struct flow_tnl *tun_key)
if (tun_key->flags & FLOW_TNL_F_CSUM) {
nl_msg_put_flag(a, OVS_TUNNEL_KEY_ATTR_CSUM);
}
if (tun_key->flags & FLOW_TNL_F_OAM) {
nl_msg_put_flag(a, OVS_TUNNEL_KEY_ATTR_OAM);
}

nl_msg_end_nested(a, tun_key_ofs);
}
Expand All @@ -949,7 +956,8 @@ odp_mask_attr_is_exact(const struct nlattr *ma)
odp_tun_key_from_attr(ma, &tun_mask);
if (tun_mask.flags == (FLOW_TNL_F_KEY
| FLOW_TNL_F_DONT_FRAGMENT
| FLOW_TNL_F_CSUM)) {
| FLOW_TNL_F_CSUM
| FLOW_TNL_F_OAM)) {
/* The flags are exact match, check the remaining fields. */
tun_mask.flags = 0xffff;
is_exact = is_all_ones((uint8_t *)&tun_mask,
Expand Down
3 changes: 2 additions & 1 deletion lib/odp-util.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ void odp_portno_names_destroy(struct hmap *portno_names);
* - OVS_TUNNEL_KEY_ATTR_TTL 1 3 4 8
* - OVS_TUNNEL_KEY_ATTR_DONT_FRAGMENT 0 -- 4 4
* - OVS_TUNNEL_KEY_ATTR_CSUM 0 -- 4 4
* - OVS_TUNNEL_KEY_ATTR_OAM 0 -- 4 4
* OVS_KEY_ATTR_IN_PORT 4 -- 4 8
* OVS_KEY_ATTR_SKB_MARK 4 -- 4 8
* OVS_KEY_ATTR_DP_HASH 4 -- 4 8
Expand All @@ -117,7 +118,7 @@ void odp_portno_names_destroy(struct hmap *portno_names);
* OVS_KEY_ATTR_ICMPV6 2 2 4 8
* OVS_KEY_ATTR_ND 28 -- 4 32
* ----------------------------------------------------------
* total 224
* total 228
*
* We include some slack space in case the calculation isn't quite right or we
* add another field and forget to adjust this value.
Expand Down

0 comments on commit 9487259

Please sign in to comment.