aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnsis Atteka <aatteka@nicira.com>2012-11-29 14:36:49 -0800
committerAnsis Atteka <aatteka@nicira.com>2012-12-18 11:13:38 -0800
commit8c210b71d3d2c43381ef06ef24605e222d39b380 (patch)
tree54cdf74a26cc0c025045fe1fbaa826a32557e2a7
parentfa691fab1caa836f2cd158e4a40d62bdc015b47a (diff)
vswitchd: log skb_mark and skb_priority
This patch adds logging support for skb_mark and skb_priority. Acked-by: Jesse Gross <jesse@nicira.com> Signed-off-by: Ansis Atteka <aatteka@nicira.com> Conflicts: lib/ofp-util.c tests/ofproto-dpif.at
-rw-r--r--lib/match.c30
-rw-r--r--lib/match.h2
-rw-r--r--lib/meta-flow.c62
-rw-r--r--lib/meta-flow.h2
-rw-r--r--lib/odp-util.c10
-rw-r--r--lib/ofp-util.c5
-rw-r--r--tests/odp.at6
-rw-r--r--tests/ofproto-dpif.at10
-rw-r--r--tests/ovs-ofctl.at12
9 files changed, 126 insertions, 13 deletions
diff --git a/lib/match.c b/lib/match.c
index 9eb121d7..7d6e8cc9 100644
--- a/lib/match.c
+++ b/lib/match.c
@@ -56,6 +56,14 @@ match_wc_init(struct match *match, const struct flow *flow)
memset(&wc->masks.nw_proto, 0xff, sizeof wc->masks.nw_proto);
}
+ if (flow->skb_priority) {
+ memset(&wc->masks.skb_priority, 0xff, sizeof wc->masks.skb_priority);
+ }
+
+ if (flow->skb_mark) {
+ memset(&wc->masks.skb_mark, 0xff, sizeof wc->masks.skb_mark);
+ }
+
for (i = 0; i < FLOW_N_REGS; i++) {
if (flow->regs[i]) {
memset(&wc->masks.regs[i], 0xff, sizeof wc->masks.regs[i]);
@@ -273,6 +281,20 @@ match_set_in_port(struct match *match, uint16_t ofp_port)
}
void
+match_set_skb_priority(struct match *match, uint32_t skb_priority)
+{
+ match->wc.masks.skb_priority = UINT32_MAX;
+ match->flow.skb_priority = skb_priority;
+}
+
+void
+match_set_skb_mark(struct match *match, uint32_t skb_mark)
+{
+ match->wc.masks.skb_mark = UINT32_MAX;
+ match->flow.skb_mark = skb_mark;
+}
+
+void
match_set_dl_type(struct match *match, ovs_be16 dl_type)
{
match->wc.masks.dl_type = htons(UINT16_MAX);
@@ -765,6 +787,14 @@ match_format(const struct match *match, struct ds *s, unsigned int priority)
ds_put_format(s, "priority=%u,", priority);
}
+ if (wc->masks.skb_mark) {
+ ds_put_format(s, "skb_mark=%#"PRIx32",", f->skb_mark);
+ }
+
+ if (wc->masks.skb_priority) {
+ ds_put_format(s, "skb_priority=%#"PRIx32",", f->skb_priority);
+ }
+
if (wc->masks.dl_type) {
skip_type = true;
if (f->dl_type == htons(ETH_TYPE_IP)) {
diff --git a/lib/match.h b/lib/match.h
index fa3196a5..ff0b5f2a 100644
--- a/lib/match.h
+++ b/lib/match.h
@@ -61,6 +61,8 @@ void match_set_tun_tos_masked(struct match *match, uint8_t tos, uint8_t mask);
void match_set_tun_flags(struct match *match, uint16_t flags);
void match_set_tun_flags_masked(struct match *match, uint16_t flags, uint16_t mask);
void match_set_in_port(struct match *, uint16_t ofp_port);
+void match_set_skb_mark(struct match *, uint32_t skb_mark);
+void match_set_skb_priority(struct match *, uint32_t skb_priority);
void match_set_dl_type(struct match *, ovs_be16);
void match_set_dl_src(struct match *, const uint8_t[6]);
void match_set_dl_src_masked(struct match *, const uint8_t dl_src[6],
diff --git a/lib/meta-flow.c b/lib/meta-flow.c
index a967fa7f..dd643ee4 100644
--- a/lib/meta-flow.c
+++ b/lib/meta-flow.c
@@ -118,6 +118,24 @@ static const struct mf_field mf_fields[MFF_N_IDS] = {
false,
NXM_OF_IN_PORT, "NXM_OF_IN_PORT",
OXM_OF_IN_PORT, "OXM_OF_IN_PORT",
+ }, {
+ MFF_SKB_PRIORITY, "skb_priority", NULL,
+ MF_FIELD_SIZES(be32),
+ MFM_NONE,
+ MFS_HEXADECIMAL,
+ MFP_NONE,
+ false,
+ 0, NULL,
+ 0, NULL,
+ }, {
+ MFF_SKB_MARK, "skb_mark", NULL,
+ MF_FIELD_SIZES(be32),
+ MFM_NONE,
+ MFS_HEXADECIMAL,
+ MFP_NONE,
+ false,
+ 0, NULL,
+ 0, NULL,
},
#define REGISTER(IDX) \
@@ -629,6 +647,10 @@ mf_is_all_wild(const struct mf_field *mf, const struct flow_wildcards *wc)
return !wc->masks.metadata;
case MFF_IN_PORT:
return !wc->masks.in_port;
+ case MFF_SKB_PRIORITY:
+ return !wc->masks.skb_priority;
+ case MFF_SKB_MARK:
+ return !wc->masks.skb_mark;
CASE_MFF_REGS:
return !wc->masks.regs[mf->id - MFF_REG0];
@@ -829,6 +851,8 @@ mf_is_value_valid(const struct mf_field *mf, const union mf_value *value)
case MFF_TUN_FLAGS:
case MFF_METADATA:
case MFF_IN_PORT:
+ case MFF_SKB_PRIORITY:
+ case MFF_SKB_MARK:
CASE_MFF_REGS:
case MFF_ETH_SRC:
case MFF_ETH_DST:
@@ -919,6 +943,14 @@ mf_get_value(const struct mf_field *mf, const struct flow *flow,
value->be16 = htons(flow->in_port);
break;
+ case MFF_SKB_PRIORITY:
+ value->be32 = flow->skb_priority;
+ break;
+
+ case MFF_SKB_MARK:
+ value->be32 = flow->skb_mark;
+ break;
+
CASE_MFF_REGS:
value->be32 = htonl(flow->regs[mf->id - MFF_REG0]);
break;
@@ -1078,6 +1110,14 @@ mf_set_value(const struct mf_field *mf,
match_set_in_port(match, ntohs(value->be16));
break;
+ case MFF_SKB_PRIORITY:
+ match_set_skb_priority(match, ntohl(value->be32));
+ break;
+
+ case MFF_SKB_MARK:
+ match_set_skb_mark(match, ntohl(value->be32));
+ break;
+
CASE_MFF_REGS:
match_set_reg(match, mf->id - MFF_REG0, ntohl(value->be32));
break;
@@ -1237,6 +1277,14 @@ mf_set_flow_value(const struct mf_field *mf,
flow->in_port = ntohs(value->be16);
break;
+ case MFF_SKB_PRIORITY:
+ flow->skb_priority = ntohl(value->be32);
+ break;
+
+ case MFF_SKB_MARK:
+ flow->skb_mark = ntohl(value->be32);
+ break;
+
CASE_MFF_REGS:
flow->regs[mf->id - MFF_REG0] = ntohl(value->be32);
break;
@@ -1411,6 +1459,16 @@ mf_set_wild(const struct mf_field *mf, struct match *match)
match->wc.masks.in_port = 0;
break;
+ case MFF_SKB_PRIORITY:
+ match->flow.skb_priority = 0;
+ match->wc.masks.skb_priority = 0;
+ break;
+
+ case MFF_SKB_MARK:
+ match->flow.skb_mark = 0;
+ match->wc.masks.skb_mark = 0;
+ break;
+
CASE_MFF_REGS:
match_set_reg_masked(match, mf->id - MFF_REG0, 0, 0);
break;
@@ -1565,6 +1623,8 @@ mf_set(const struct mf_field *mf,
switch (mf->id) {
case MFF_IN_PORT:
+ case MFF_SKB_MARK:
+ case MFF_SKB_PRIORITY:
case MFF_ETH_TYPE:
case MFF_DL_VLAN:
case MFF_DL_VLAN_PCP:
@@ -1764,6 +1824,8 @@ mf_random_value(const struct mf_field *mf, union mf_value *value)
case MFF_TUN_FLAGS:
case MFF_METADATA:
case MFF_IN_PORT:
+ case MFF_SKB_MARK:
+ case MFF_SKB_PRIORITY:
CASE_MFF_REGS:
case MFF_ETH_SRC:
case MFF_ETH_DST:
diff --git a/lib/meta-flow.h b/lib/meta-flow.h
index 1c49306e..36758836 100644
--- a/lib/meta-flow.h
+++ b/lib/meta-flow.h
@@ -39,6 +39,8 @@ enum mf_field_id {
MFF_TUN_TOS, /* u8 */
MFF_METADATA, /* be64 */
MFF_IN_PORT, /* be16 */
+ MFF_SKB_PRIORITY, /* be32 */
+ MFF_SKB_MARK, /* be32 */
#if FLOW_N_REGS > 0
MFF_REG0, /* be32 */
diff --git a/lib/odp-util.c b/lib/odp-util.c
index 78e20c8a..2a23f1f6 100644
--- a/lib/odp-util.c
+++ b/lib/odp-util.c
@@ -92,7 +92,7 @@ ovs_key_attr_to_string(enum ovs_key_attr attr)
switch (attr) {
case OVS_KEY_ATTR_UNSPEC: return "unspec";
case OVS_KEY_ATTR_ENCAP: return "encap";
- case OVS_KEY_ATTR_PRIORITY: return "priority";
+ case OVS_KEY_ATTR_PRIORITY: return "skb_priority";
case OVS_KEY_ATTR_SKB_MARK: return "skb_mark";
case OVS_KEY_ATTR_TUN_ID: return "tun_id";
case OVS_KEY_ATTR_IPV4_TUNNEL: return "ipv4_tunnel";
@@ -723,11 +723,11 @@ format_odp_key_attr(const struct nlattr *a, struct ds *ds)
break;
case OVS_KEY_ATTR_PRIORITY:
- ds_put_format(ds, "(%"PRIu32")", nl_attr_get_u32(a));
+ ds_put_format(ds, "(%#"PRIx32")", nl_attr_get_u32(a));
break;
case OVS_KEY_ATTR_SKB_MARK:
- ds_put_format(ds, "(%"PRIu32")", nl_attr_get_u32(a));
+ ds_put_format(ds, "(%#"PRIx32")", nl_attr_get_u32(a));
break;
case OVS_KEY_ATTR_TUN_ID:
@@ -943,7 +943,7 @@ parse_odp_key_attr(const char *s, const struct simap *port_names,
unsigned long long int priority;
int n = -1;
- if (sscanf(s, "priority(%lli)%n", &priority, &n) > 0 && n > 0) {
+ if (sscanf(s, "skb_priority(%llx)%n", &priority, &n) > 0 && n > 0) {
nl_msg_put_u32(key, OVS_KEY_ATTR_PRIORITY, priority);
return n;
}
@@ -953,7 +953,7 @@ parse_odp_key_attr(const char *s, const struct simap *port_names,
unsigned long long int mark;
int n = -1;
- if (sscanf(s, "skb_mark(%lli)%n", &mark, &n) > 0 && n > 0) {
+ if (sscanf(s, "skb_mark(%llx)%n", &mark, &n) > 0 && n > 0) {
nl_msg_put_u32(key, OVS_KEY_ATTR_SKB_MARK, mark);
return n;
}
diff --git a/lib/ofp-util.c b/lib/ofp-util.c
index a8f8222e..a2474420 100644
--- a/lib/ofp-util.c
+++ b/lib/ofp-util.c
@@ -918,6 +918,11 @@ ofputil_usable_protocols(const struct match *match)
return 0;
}
+ /* skb_mark and skb_priority can't be sent in a flow_mod */
+ if (wc->masks.skb_mark || wc->masks.skb_priority) {
+ return 0;
+ }
+
/* NXM and OF1.1+ supports bitwise matching on ethernet addresses. */
if (!eth_mask_is_exact(wc->masks.dl_src)
&& !eth_addr_is_zero(wc->masks.dl_src)) {
diff --git a/tests/odp.at b/tests/odp.at
index a5f6dbe5..43b79d63 100644
--- a/tests/odp.at
+++ b/tests/odp.at
@@ -24,7 +24,7 @@ in_port(1),eth(src=00:01:02:03:04:05,dst=10:11:12:13:14:15),eth_type(0x86dd),ipv
in_port(1),eth(src=00:01:02:03:04:05,dst=10:11:12:13:14:15),eth_type(0x86dd),ipv6(src=::1,dst=::2,label=0,proto=58,tclass=0,hlimit=128,frag=no),icmpv6(type=136,code=0),nd(target=::3,tll=00:0a:0b:0c:0d:0e)
in_port(1),eth(src=00:01:02:03:04:05,dst=10:11:12:13:14:15),eth_type(0x86dd),ipv6(src=::1,dst=::2,label=0,proto=58,tclass=0,hlimit=128,frag=no),icmpv6(type=136,code=0),nd(target=::3,sll=00:05:06:07:08:09,tll=00:0a:0b:0c:0d:0e)
in_port(1),eth(src=00:01:02:03:04:05,dst=10:11:12:13:14:15),eth_type(0x0806),arp(sip=1.2.3.4,tip=5.6.7.8,op=1,sha=00:0f:10:11:12:13,tha=00:14:15:16:17:18)
-skb_mark(17185),in_port(1),eth(src=00:01:02:03:04:05,dst=10:11:12:13:14:15),eth_type(0x86dd),ipv6(src=::1,dst=::2,label=0,proto=58,tclass=0,hlimit=128,frag=no),icmpv6(type=136,code=0),nd(target=::3,sll=00:05:06:07:08:09,tll=00:0a:0b:0c:0d:0e)
+skb_mark(0x1234),in_port(1),eth(src=00:01:02:03:04:05,dst=10:11:12:13:14:15),eth_type(0x86dd),ipv6(src=::1,dst=::2,label=0,proto=58,tclass=0,hlimit=128,frag=no),icmpv6(type=136,code=0),nd(target=::3,sll=00:05:06:07:08:09,tll=00:0a:0b:0c:0d:0e)
])
(echo '# Valid forms without tun_id or VLAN header.'
@@ -41,7 +41,7 @@ s/$/)/' odp-base.txt
echo
echo '# Valid forms with QoS priority.'
- sed 's/^/priority(1234),/' odp-base.txt
+ sed 's/^/skb_priority(0x1234),/' odp-base.txt
echo
echo '# Valid forms with tun_id and VLAN headers.'
@@ -51,7 +51,7 @@ s/$/)/' odp-base.txt
echo
echo '# Valid forms with QOS priority, tun_id, and VLAN headers.'
- sed 's/^/priority(1234),tun_id(0xfedcba9876543210),/
+ sed 's/^/skb_priority(0x1234),tun_id(0xfedcba9876543210),/
s/\(eth([[^)]]*)\),*/\1,eth_type(0x8100),vlan(vid=99,pcp=7),encap(/
s/$/)/' odp-base.txt
diff --git a/tests/ofproto-dpif.at b/tests/ofproto-dpif.at
index 0922e1f1..8aa0e10b 100644
--- a/tests/ofproto-dpif.at
+++ b/tests/ofproto-dpif.at
@@ -139,11 +139,11 @@ AT_CHECK([ovs-appctl ofproto/trace br0 'in_port(9),eth(src=50:54:00:00:00:05,dst
AT_CHECK([tail -1 stdout], [0],
[Datapath actions: dnl
0,dnl
-set(ipv4(src=1.1.1.1,dst=2.2.2.2,proto=1,tos=0x7,ttl=128,frag=no)),set(priority(1)),1,dnl
-set(ipv4(src=1.1.1.1,dst=2.2.2.2,proto=1,tos=0xb,ttl=128,frag=no)),set(priority(2)),1,dnl
+set(ipv4(src=1.1.1.1,dst=2.2.2.2,proto=1,tos=0x7,ttl=128,frag=no)),set(skb_priority(0x1)),1,dnl
+set(ipv4(src=1.1.1.1,dst=2.2.2.2,proto=1,tos=0xb,ttl=128,frag=no)),set(skb_priority(0x2)),1,dnl
1,dnl
-set(ipv4(src=1.1.1.1,dst=2.2.2.2,proto=1,tos=0x7,ttl=128,frag=no)),set(priority(1)),1,dnl
-set(ipv4(src=1.1.1.1,dst=2.2.2.2,proto=1,tos=0xff,ttl=128,frag=no)),set(priority(0)),1,dnl
+set(ipv4(src=1.1.1.1,dst=2.2.2.2,proto=1,tos=0x7,ttl=128,frag=no)),set(skb_priority(0x1)),1,dnl
+set(ipv4(src=1.1.1.1,dst=2.2.2.2,proto=1,tos=0xff,ttl=128,frag=no)),set(skb_priority(0)),1,dnl
set(ipv4(src=1.1.1.1,dst=2.2.2.2,proto=1,tos=0x3,ttl=128,frag=no)),1,dnl
0
])
@@ -209,7 +209,7 @@ AT_CHECK([tail -1 stdout], [0],
AT_CHECK([ovs-appctl ofproto/trace br0 'in_port(4),eth(src=00:00:00:00:00:01,dst=00:00:00:00:00:02),eth_type(0x0900)'], [0], [stdout])
AT_CHECK([tail -1 stdout], [0],
- [Datapath actions: set(priority(1)),0,1,2,set(priority(2)),3,set(priority(1)),6,7
+ [Datapath actions: set(skb_priority(0x1)),0,1,2,set(skb_priority(0x2)),3,set(skb_priority(0x1)),6,7
])
OVS_VSWITCHD_STOP
AT_CLEANUP
diff --git a/tests/ovs-ofctl.at b/tests/ovs-ofctl.at
index 107c5419..7b9ac442 100644
--- a/tests/ovs-ofctl.at
+++ b/tests/ovs-ofctl.at
@@ -43,6 +43,18 @@ AT_CHECK([ovs-ofctl parse-flows flows.txt
AT_CLEANUP
+AT_SETUP([ovs-ofctl parse-flows (skb_mark and skb_priority)])
+AT_DATA([flows.txt], [[
+skb_mark=0x12345678,skb_priority=0x12341234,tcp,tp_src=123,actions=flood
+]])
+
+AT_CHECK([ovs-ofctl parse-flows flows.txt
+], [1], [usable protocols: none
+], [stderr])
+
+AT_CLEANUP
+
+
AT_SETUP([ovs-ofctl parse-flows (NXM)])
AT_DATA([flows.txt], [[
# comment