/*
- * Copyright (c) 2011, 2012 Nicira, Inc.
+ * Copyright (c) 2011, 2012, 2013 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include "meta-flow.h"
-#include <assert.h>
#include <errno.h>
#include <limits.h>
#include <netinet/icmp6.h>
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) \
const struct mf_field *
mf_from_id(enum mf_field_id id)
{
- assert((unsigned int) id < MFF_N_IDS);
+ ovs_assert((unsigned int) id < MFF_N_IDS);
return &mf_fields[id];
}
nxm_init_add_field(const struct mf_field *mf, uint32_t header)
{
if (header) {
- assert(!mf_from_nxm_header__(header));
+ ovs_assert(!mf_from_nxm_header__(header));
add_nxm_field(header, mf);
if (mf->maskable != MFM_NONE) {
add_nxm_field(NXM_MAKE_WILD_HEADER(header), mf);
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];
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:
value->be16 = htons(flow->in_port);
break;
+ case MFF_SKB_PRIORITY:
+ value->be32 = htonl(flow->skb_priority);
+ break;
+
+ case MFF_SKB_MARK:
+ value->be32 = htonl(flow->skb_mark);
+ break;
+
CASE_MFF_REGS:
value->be32 = htonl(flow->regs[mf->id - MFF_REG0]);
break;
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;
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;
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;
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:
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:
uint8_t mac[ETH_ADDR_LEN],
uint8_t mask[ETH_ADDR_LEN])
{
- assert(mf->n_bytes == ETH_ADDR_LEN);
+ ovs_assert(mf->n_bytes == ETH_ADDR_LEN);
switch (sscanf(s, ETH_ADDR_SCAN_FMT"/"ETH_ADDR_SCAN_FMT,
ETH_ADDR_SCAN_ARGS(mac), ETH_ADDR_SCAN_ARGS(mask))){
{
int prefix;
- assert(mf->n_bytes == sizeof *ip);
+ ovs_assert(mf->n_bytes == sizeof *ip);
if (sscanf(s, IP_SCAN_FMT"/"IP_SCAN_FMT,
IP_SCAN_ARGS(ip), IP_SCAN_ARGS(mask)) == IP_SCAN_COUNT * 2) {
const char *name, *netmask;
int retval;
- assert(mf->n_bytes == sizeof *value);
+ ovs_assert(mf->n_bytes == sizeof *value);
name = strtok_r(str, "/", &save_ptr);
retval = name ? lookup_ipv6(name, value) : EINVAL;
{
uint16_t port;
- assert(mf->n_bytes == sizeof(ovs_be16));
+ ovs_assert(mf->n_bytes == sizeof(ovs_be16));
if (*s == '-') {
return xasprintf("%s: negative values not supported for %s",
s, mf->name);
}
static char *
-mf_from_tun_flags_string(const char *s, ovs_be16 *valuep)
+mf_from_tun_flags_string(const char *s, ovs_be16 *valuep, ovs_be16 *maskp)
{
if (!parse_flow_tun_flags(s, flow_tun_flag_to_string, valuep)) {
+ *maskp = htons(UINT16_MAX);
return NULL;
}
mf_parse(const struct mf_field *mf, const char *s,
union mf_value *value, union mf_value *mask)
{
- if (!strcasecmp(s, "any") || !strcmp(s, "*")) {
+ if (!strcmp(s, "*")) {
memset(value, 0, mf->n_bytes);
memset(mask, 0, mf->n_bytes);
return NULL;
return mf_from_frag_string(s, &value->u8, &mask->u8);
case MFS_TNL_FLAGS:
- return mf_from_tun_flags_string(s, &value->be16);
+ ovs_assert(mf->n_bytes == sizeof(ovs_be16));
+ return mf_from_tun_flags_string(s, &value->be16, &mask->be16);
}
NOT_REACHED();
}
unsigned long long int integer;
int i;
- assert(mf->n_bytes <= 8);
+ ovs_assert(mf->n_bytes <= 8);
integer = 0;
for (i = 0; i < mf->n_bytes; i++) {