Re: [ovs-dev] [RFC PATCH 06/13] tunneling: extend flow_tnl with ipv6 addresses

2015-05-29 Thread Ben Pfaff
On Thu, May 14, 2015 at 08:12:37PM +0200, Jiri Benc wrote:
> Note that because there's been no prerequisite on the outer protocol,
> we cannot add it now. Instead, treat the ipv4 and ipv6 dst fields in the way
> that either both are null, or at most one of them is non-null.
> 
> Signed-off-by: Jiri Benc 

At this point I started getting patch rejects against current master.  I
hope that you can apply my comments to this point and post a rebased
version.

Thanks,

Ben.
___
dev mailing list
[email protected]
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [RFC PATCH 06/13] tunneling: extend flow_tnl with ipv6 addresses

2015-05-14 Thread Jiri Benc
Note that because there's been no prerequisite on the outer protocol,
we cannot add it now. Instead, treat the ipv4 and ipv6 dst fields in the way
that either both are null, or at most one of them is non-null.

Signed-off-by: Jiri Benc 
---
 lib/dpif.c   |  6 --
 lib/flow.c   | 19 ++-
 lib/match.c  | 34 ++
 lib/match.h  |  6 ++
 lib/odp-util.c   | 30 ++
 lib/odp-util.h   |  6 --
 lib/packets.h|  2 ++
 ofproto/tunnel.c |  9 +++--
 ofproto/tunnel.h |  2 +-
 9 files changed, 98 insertions(+), 16 deletions(-)

diff --git a/lib/dpif.c b/lib/dpif.c
index b8f30a50349c..a8bf69f16d17 100644
--- a/lib/dpif.c
+++ b/lib/dpif.c
@@ -1102,8 +1102,10 @@ dpif_execute_helper_cb(void *aux_, struct dp_packet 
**packets, int cnt,
 struct ofpbuf execute_actions;
 uint64_t stub[256 / 8];
 struct pkt_metadata *md = &packet->md;
+bool dst_set;
 
-if (md->tunnel.ip_dst) {
+dst_set = md->tunnel.ip_dst || ipv6_addr_is_set(&md->tunnel.ipv6_dst);
+if (dst_set) {
 /* The Linux kernel datapath throws away the tunnel information
  * that we supply as metadata.  We have to use a "set" action to
  * supply it. */
@@ -1124,7 +1126,7 @@ dpif_execute_helper_cb(void *aux_, struct dp_packet 
**packets, int cnt,
 aux->error = dpif_execute(aux->dpif, &execute);
 log_execute_message(aux->dpif, &execute, true, aux->error);
 
-if (md->tunnel.ip_dst) {
+if (dst_set) {
 ofpbuf_uninit(&execute_actions);
 }
 break;
diff --git a/lib/flow.c b/lib/flow.c
index e54280a45f40..752cf5f15c50 100644
--- a/lib/flow.c
+++ b/lib/flow.c
@@ -432,7 +432,7 @@ miniflow_extract(struct dp_packet *packet, struct miniflow 
*dst)
 uint8_t nw_frag, nw_tos, nw_ttl, nw_proto;
 
 /* Metadata. */
-if (md->tunnel.ip_dst) {
+if (md->tunnel.ip_dst || ipv6_addr_is_set(&md->tunnel.ipv6_dst)) {
 miniflow_push_words(mf, tunnel, &md->tunnel,
 sizeof md->tunnel / sizeof(uint64_t));
 }
@@ -920,12 +920,17 @@ void flow_wildcards_init_for_packet(struct flow_wildcards 
*wc,
 /* Update this function whenever struct flow changes. */
 BUILD_ASSERT_DECL(FLOW_WC_SEQ == 31);
 
-if (flow->tunnel.ip_dst) {
+if (flow->tunnel.ip_dst || ipv6_addr_is_set(&flow->tunnel.ipv6_dst)) {
 if (flow->tunnel.flags & FLOW_TNL_F_KEY) {
 WC_MASK_FIELD(wc, tunnel.tun_id);
 }
-WC_MASK_FIELD(wc, tunnel.ip_src);
-WC_MASK_FIELD(wc, tunnel.ip_dst);
+if (flow->tunnel.ip_dst) {
+WC_MASK_FIELD(wc, tunnel.ip_src);
+WC_MASK_FIELD(wc, tunnel.ip_dst);
+} else {
+WC_MASK_FIELD(wc, tunnel.ipv6_src);
+WC_MASK_FIELD(wc, tunnel.ipv6_dst);
+}
 WC_MASK_FIELD(wc, tunnel.flags);
 WC_MASK_FIELD(wc, tunnel.ip_tos);
 WC_MASK_FIELD(wc, tunnel.ip_ttl);
@@ -1019,7 +1024,11 @@ flow_wc_map(const struct flow *flow)
 /* Update this function whenever struct flow changes. */
 BUILD_ASSERT_DECL(FLOW_WC_SEQ == 31);
 
-uint64_t map = (flow->tunnel.ip_dst) ? MINIFLOW_MAP(tunnel) : 0;
+uint64_t map = 0;
+
+if (flow->tunnel.ip_dst || ipv6_addr_is_set(&flow->tunnel.ipv6_dst)) {
+map |= MINIFLOW_MAP(tunnel);
+}
 
 /* Metadata fields that can appear on packet input. */
 map |= MINIFLOW_MAP(skb_priority) | MINIFLOW_MAP(pkt_mark)
diff --git a/lib/match.c b/lib/match.c
index 7d0b4095fa99..8ea4af8e2455 100644
--- a/lib/match.c
+++ b/lib/match.c
@@ -186,6 +186,36 @@ match_set_tun_dst_masked(struct match *match, ovs_be32 
dst, ovs_be32 mask)
 }
 
 void
+match_set_tun_ipv6_src(struct match *match, const struct in6_addr *src)
+{
+match->flow.tunnel.ipv6_src = *src;
+match->wc.masks.tunnel.ipv6_src = in6addr_exact;
+}
+
+void
+match_set_tun_ipv6_src_masked(struct match *match, const struct in6_addr *src,
+  const struct in6_addr *mask)
+{
+match->flow.tunnel.ipv6_src = ipv6_addr_bitand(src, mask);
+match->wc.masks.tunnel.ipv6_src = *mask;
+}
+
+void
+match_set_tun_ipv6_dst(struct match *match, const struct in6_addr *dst)
+{
+match->flow.tunnel.ipv6_dst = *dst;
+match->wc.masks.tunnel.ipv6_dst = in6addr_exact;
+}
+
+void
+match_set_tun_ipv6_dst_masked(struct match *match, const struct in6_addr *dst,
+  const struct in6_addr *mask)
+{
+match->flow.tunnel.ipv6_dst = ipv6_addr_bitand(dst, mask);
+match->wc.masks.tunnel.ipv6_dst = *mask;
+}
+
+void
 match_set_tun_ttl(struct match *match, uint8_t ttl)
 {
 match_set_tun_ttl_masked(match, ttl, UINT8_MAX);
@@ -877,6 +907,10 @@ format_flow_tunnel(struct ds *s, const struct match *match)
 format_be64_masked(s, "tun_id", tnl->tun_id, wc->masks.tunnel.tun_id);
 format_ip_netmask(s, "tun_src", tnl->ip_src, wc->masks.tunnel.ip_src