[ovs-dev] [PATCH 3/7] match: Add helper function to set nw_ttl with mask

Roi Dayan roid at mellanox.com
Mon Aug 7 15:19:07 UTC 2017


From: Paul Blakey <paulb at mellanox.com>

Add help function match_set_nw_ttl_masked()
Will be used later to set ttl value.

Signed-off-by: Paul Blakey <paulb at mellanox.com>
Reviewed-by: Roi Dayan <roid at mellanox.com>
---
 include/openvswitch/match.h | 3 ++-
 lib/match.c                 | 7 +++++++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/include/openvswitch/match.h b/include/openvswitch/match.h
index 1b43de0..030a137 100644
--- a/include/openvswitch/match.h
+++ b/include/openvswitch/match.h
@@ -168,7 +168,8 @@ void match_set_nw_dst(struct match *, ovs_be32);
 void match_set_nw_dst_masked(struct match *, ovs_be32 ip, ovs_be32 mask);
 void match_set_nw_dscp(struct match *, uint8_t);
 void match_set_nw_ecn(struct match *, uint8_t);
-void match_set_nw_ttl(struct match *, uint8_t);
+void match_set_nw_ttl(struct match *, uint8_t nw_ttl);
+void match_set_nw_ttl_masked(struct match *, uint8_t nw_ttl, uint8_t mask);
 void match_set_nw_frag(struct match *, uint8_t nw_frag);
 void match_set_nw_frag_masked(struct match *, uint8_t nw_frag, uint8_t mask);
 void match_set_icmp_type(struct match *, uint8_t);
diff --git a/lib/match.c b/lib/match.c
index f5288e3..3cfa6b3 100644
--- a/lib/match.c
+++ b/lib/match.c
@@ -889,6 +889,13 @@ match_set_nw_ttl(struct match *match, uint8_t nw_ttl)
 }
 
 void
+match_set_nw_ttl_masked(struct match *match, uint8_t nw_ttl, uint8_t mask)
+{
+    match->flow.nw_ttl = nw_ttl & mask;
+    match->wc.masks.nw_ttl = mask;
+}
+
+void
 match_set_nw_frag(struct match *match, uint8_t nw_frag)
 {
     match->wc.masks.nw_frag |= FLOW_NW_FRAG_MASK;
-- 
2.8.0



More information about the dev mailing list