aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesse Gross <jesse@nicira.com>2012-11-01 15:50:16 -0700
committerJesse Gross <jesse@nicira.com>2012-11-01 16:53:42 -0700
commit58299b914fca63d3c24732f09cb5e14f44b41102 (patch)
tree9509a55be476ec4ef4cc9482fe6bf0a01a55215a
parentfb46be6b9323e91e18344f1a30b1e97effa87853 (diff)
odp: Enable parsing ipv4_tunnel key.
We can format ipv4_tunnel keys from the kernel but can't currently parse them. Userspace doesn't know how to do anything with this information but this support enables utilities like ovs-dpctl and ovs-appctl ofproto/trace to show useful information. Bug #13785 Signed-off-by: Jesse Gross <jesse@nicira.com>
-rw-r--r--lib/odp-util.c24
-rw-r--r--tests/odp.at1
2 files changed, 25 insertions, 0 deletions
diff --git a/lib/odp-util.c b/lib/odp-util.c
index 9ed17ed8..4084e55d 100644
--- a/lib/odp-util.c
+++ b/lib/odp-util.c
@@ -925,6 +925,30 @@ parse_odp_key_attr(const char *s, const struct simap *port_names,
}
{
+ char tun_id_s[32];
+ unsigned long long int flags;
+ int tos, ttl;
+ struct ovs_key_ipv4_tunnel tun_key;
+ int n = -1;
+
+ if (sscanf(s, "ipv4_tunnel(tun_id=%31[x0123456789abcdefABCDEF],"
+ "flags=%lli,src="IP_SCAN_FMT",dst="IP_SCAN_FMT
+ ",tos=%i,ttl=%i)%n", tun_id_s, &flags,
+ IP_SCAN_ARGS(&tun_key.ipv4_src),
+ IP_SCAN_ARGS(&tun_key.ipv4_dst), &tos, &ttl,
+ &n) > 0 && n > 0) {
+ tun_key.tun_id = htonll(strtoull(tun_id_s, NULL, 0));
+ tun_key.tun_flags = flags;
+ tun_key.ipv4_tos = tos;
+ tun_key.ipv4_ttl = ttl;
+ memset(&tun_key.pad, 0, sizeof tun_key.pad);
+ nl_msg_put_unspec(key, OVS_KEY_ATTR_IPV4_TUNNEL, &tun_key,
+ sizeof tun_key);
+ return n;
+ }
+ }
+
+ {
unsigned long long int in_port;
int n = -1;
diff --git a/tests/odp.at b/tests/odp.at
index 9617af26..505e4c83 100644
--- a/tests/odp.at
+++ b/tests/odp.at
@@ -91,6 +91,7 @@ push_vlan(tpid=0x9100,vid=13,pcp=5)
push_vlan(tpid=0x9100,vid=13,pcp=5,cfi=0)
pop_vlan
sample(sample=9.7%,actions(1,2,3,push_vlan(vid=1,pcp=2)))
+set(ipv4_tunnel(tun_id=0xabcdef1234567890,flags=0x0,src=1.1.1.1,dst=2.2.2.2,tos=0x0,ttl=64))
])
AT_CHECK_UNQUOTED([test-odp parse-actions < actions.txt], [0],
[`cat actions.txt`