Skip to content

Commit

Permalink
lib/tc: Handle ttl for ipv6 too
Browse files Browse the repository at this point in the history
TTL can and should be used to match on IPv6's hop-limit, fix that.

Fixes: ab7ecf2 ('netdev-tc-offloads: Add nw_ttl matching using flower')
Fixes: 0b4b520 ('tc: Add ip layer ttl matching')
Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
Reviewed-by: Roi Dayan <roid@mellanox.com>
Signed-off-by: Simon Horman <simon.horman@netronome.com>
  • Loading branch information
ogerlitz authored and shorman-netronome committed Aug 2, 2018
1 parent 7a9d6ff commit 1dc1a8c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/netdev-tc-offloads.c
Expand Up @@ -987,8 +987,10 @@ netdev_tc_flow_put(struct netdev *netdev, struct match *match,
if (is_ip_any(key)) {
flower.key.ip_proto = key->nw_proto;
flower.mask.ip_proto = mask->nw_proto;
mask->nw_proto = 0;
flower.key.ip_ttl = key->nw_ttl;
flower.mask.ip_ttl = mask->nw_ttl;
mask->nw_ttl = 0;

if (mask->nw_frag & FLOW_NW_FRAG_ANY) {
flower.mask.flags |= TCA_FLOWER_KEY_FLAGS_IS_FRAGMENT;
Expand Down Expand Up @@ -1035,8 +1037,6 @@ netdev_tc_flow_put(struct netdev *netdev, struct match *match,
}

mask->nw_tos = 0;
mask->nw_proto = 0;
mask->nw_ttl = 0;

if (key->dl_type == htons(ETH_P_IP)) {
flower.key.ipv4.ipv4_src = key->nw_src;
Expand Down
3 changes: 2 additions & 1 deletion lib/tc.c
Expand Up @@ -1589,6 +1589,8 @@ nl_msg_put_flower_options(struct ofpbuf *request, struct tc_flower *flower)
FLOWER_PUT_MASKED_VALUE(src_mac, TCA_FLOWER_KEY_ETH_SRC);

if (host_eth_type == ETH_P_IP || host_eth_type == ETH_P_IPV6) {
FLOWER_PUT_MASKED_VALUE(ip_ttl, TCA_FLOWER_KEY_IP_TTL);

if (flower->mask.ip_proto && flower->key.ip_proto) {
nl_msg_put_u8(request, TCA_FLOWER_KEY_IP_PROTO,
flower->key.ip_proto);
Expand Down Expand Up @@ -1617,7 +1619,6 @@ nl_msg_put_flower_options(struct ofpbuf *request, struct tc_flower *flower)
if (host_eth_type == ETH_P_IP) {
FLOWER_PUT_MASKED_VALUE(ipv4.ipv4_src, TCA_FLOWER_KEY_IPV4_SRC);
FLOWER_PUT_MASKED_VALUE(ipv4.ipv4_dst, TCA_FLOWER_KEY_IPV4_DST);
FLOWER_PUT_MASKED_VALUE(ip_ttl, TCA_FLOWER_KEY_IP_TTL);
} else if (host_eth_type == ETH_P_IPV6) {
FLOWER_PUT_MASKED_VALUE(ipv6.ipv6_src, TCA_FLOWER_KEY_IPV6_SRC);
FLOWER_PUT_MASKED_VALUE(ipv6.ipv6_dst, TCA_FLOWER_KEY_IPV6_DST);
Expand Down

0 comments on commit 1dc1a8c

Please sign in to comment.