Skip to content

Commit

Permalink
flow: Rename skb_mark to pkt_mark.
Browse files Browse the repository at this point in the history
The skb_mark field is currently only available with the Linux datapath
and is only used internally. However, it is desirable to expose this
through OpenFlow and when it is exposed ideally it would not be system-
specific. In preparation for this, skb_mark is rename to pkt_mark in
internal data structures for consistency.

This does not rename the Linux interfaces because doing so would break
the API. It would not necessarily be desirable to do anyways since in
Linux-specific code it is clearer to use the actual name rather than a
generic one. This can lead to confusion in some places, however, because
we do not always strictly separate generic and platform dependent code
(one example is actions). This seems inevitable though at this point if
the lower and upper layers have different names (as they must given the
above requirements).

Signed-off-by: Jesse Gross <[email protected]>
Acked-by: Andy Zhou <[email protected]>
  • Loading branch information
jessegross committed Aug 13, 2013
1 parent 15d0658 commit 1362e24
Show file tree
Hide file tree
Showing 18 changed files with 69 additions and 69 deletions.
6 changes: 3 additions & 3 deletions lib/dpif-netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ static void dp_netdev_execute_actions(struct dp_netdev *,
static void dp_netdev_port_input(struct dp_netdev *dp,
struct dp_netdev_port *port,
struct ofpbuf *packet, uint32_t skb_priority,
uint32_t skb_mark, const struct flow_tnl *tnl);
uint32_t pkt_mark, const struct flow_tnl *tnl);

static struct dpif_netdev *
dpif_netdev_cast(const struct dpif *dpif)
Expand Down Expand Up @@ -1135,7 +1135,7 @@ dp_netdev_flow_used(struct dp_netdev_flow *flow, const struct ofpbuf *packet)
static void
dp_netdev_port_input(struct dp_netdev *dp, struct dp_netdev_port *port,
struct ofpbuf *packet, uint32_t skb_priority,
uint32_t skb_mark, const struct flow_tnl *tnl)
uint32_t pkt_mark, const struct flow_tnl *tnl)
{
struct dp_netdev_flow *flow;
struct flow key;
Expand All @@ -1145,7 +1145,7 @@ dp_netdev_port_input(struct dp_netdev *dp, struct dp_netdev_port *port,
return;
}
in_port_.odp_port = port->port_no;
flow_extract(packet, skb_priority, skb_mark, tnl, &in_port_, &key);
flow_extract(packet, skb_priority, pkt_mark, tnl, &in_port_, &key);
flow = dp_netdev_lookup_flow(dp, &key);
if (flow) {
dp_netdev_flow_used(flow, packet);
Expand Down
4 changes: 2 additions & 2 deletions lib/flow.c
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ parse_icmpv6(struct ofpbuf *b, struct flow *flow)
* present and has a correct length, and otherwise NULL.
*/
void
flow_extract(struct ofpbuf *packet, uint32_t skb_priority, uint32_t skb_mark,
flow_extract(struct ofpbuf *packet, uint32_t skb_priority, uint32_t pkt_mark,
const struct flow_tnl *tnl, const union flow_in_port *in_port,
struct flow *flow)
{
Expand All @@ -375,7 +375,7 @@ flow_extract(struct ofpbuf *packet, uint32_t skb_priority, uint32_t skb_mark,
flow->in_port = *in_port;
}
flow->skb_priority = skb_priority;
flow->skb_mark = skb_mark;
flow->pkt_mark = pkt_mark;

packet->l2 = b.data;
packet->l2_5 = NULL;
Expand Down
2 changes: 1 addition & 1 deletion lib/flow.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ struct flow {
ovs_be32 nw_dst; /* IPv4 destination address. */
ovs_be32 ipv6_label; /* IPv6 flow label. */
union flow_in_port in_port; /* Input port.*/
uint32_t skb_mark; /* Packet mark. */
uint32_t pkt_mark; /* Packet mark. */
ovs_be32 mpls_lse; /* MPLS label stack entry. */
uint16_t mpls_depth; /* Depth of MPLS stack. */
ovs_be16 vlan_tci; /* If 802.1Q, TCI | VLAN_CFI; otherwise 0. */
Expand Down
16 changes: 8 additions & 8 deletions lib/match.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ match_wc_init(struct match *match, const struct flow *flow)
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);
if (flow->pkt_mark) {
memset(&wc->masks.pkt_mark, 0xff, sizeof wc->masks.pkt_mark);
}

for (i = 0; i < FLOW_N_REGS; i++) {
Expand Down Expand Up @@ -138,7 +138,7 @@ match_init_exact(struct match *match, const struct flow *flow)
{
match->flow = *flow;
match->flow.skb_priority = 0;
match->flow.skb_mark = 0;
match->flow.pkt_mark = 0;
flow_wildcards_init_exact(&match->wc);
}

Expand Down Expand Up @@ -286,10 +286,10 @@ match_set_skb_priority(struct match *match, uint32_t skb_priority)
}

void
match_set_skb_mark(struct match *match, uint32_t skb_mark)
match_set_pkt_mark(struct match *match, uint32_t pkt_mark)
{
match->wc.masks.skb_mark = UINT32_MAX;
match->flow.skb_mark = skb_mark;
match->wc.masks.pkt_mark = UINT32_MAX;
match->flow.pkt_mark = pkt_mark;
}

void
Expand Down Expand Up @@ -836,8 +836,8 @@ 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.pkt_mark) {
ds_put_format(s, "pkt_mark=%#"PRIx32",", f->pkt_mark);
}

if (wc->masks.skb_priority) {
Expand Down
2 changes: 1 addition & 1 deletion lib/match.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ 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 *, ofp_port_t ofp_port);
void match_set_skb_mark(struct match *, uint32_t skb_mark);
void match_set_pkt_mark(struct match *, uint32_t pkt_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]);
Expand Down
30 changes: 15 additions & 15 deletions lib/meta-flow.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ static const struct mf_field mf_fields[MFF_N_IDS] = {
0, NULL,
0, NULL,
}, {
MFF_SKB_MARK, "skb_mark", NULL,
MFF_PKT_MARK, "pkt_mark", NULL,
MF_FIELD_SIZES(be32),
MFM_NONE,
MFS_HEXADECIMAL,
Expand Down Expand Up @@ -706,8 +706,8 @@ mf_is_all_wild(const struct mf_field *mf, const struct flow_wildcards *wc)
return !wc->masks.in_port.ofp_port;
case MFF_SKB_PRIORITY:
return !wc->masks.skb_priority;
case MFF_SKB_MARK:
return !wc->masks.skb_mark;
case MFF_PKT_MARK:
return !wc->masks.pkt_mark;
CASE_MFF_REGS:
return !wc->masks.regs[mf->id - MFF_REG0];

Expand Down Expand Up @@ -912,7 +912,7 @@ mf_is_value_valid(const struct mf_field *mf, const union mf_value *value)
case MFF_METADATA:
case MFF_IN_PORT:
case MFF_SKB_PRIORITY:
case MFF_SKB_MARK:
case MFF_PKT_MARK:
CASE_MFF_REGS:
case MFF_ETH_SRC:
case MFF_ETH_DST:
Expand Down Expand Up @@ -1026,8 +1026,8 @@ mf_get_value(const struct mf_field *mf, const struct flow *flow,
value->be32 = htonl(flow->skb_priority);
break;

case MFF_SKB_MARK:
value->be32 = htonl(flow->skb_mark);
case MFF_PKT_MARK:
value->be32 = htonl(flow->pkt_mark);
break;

CASE_MFF_REGS:
Expand Down Expand Up @@ -1216,8 +1216,8 @@ mf_set_value(const struct mf_field *mf,
match_set_skb_priority(match, ntohl(value->be32));
break;

case MFF_SKB_MARK:
match_set_skb_mark(match, ntohl(value->be32));
case MFF_PKT_MARK:
match_set_pkt_mark(match, ntohl(value->be32));
break;

CASE_MFF_REGS:
Expand Down Expand Up @@ -1405,8 +1405,8 @@ mf_set_flow_value(const struct mf_field *mf,
flow->skb_priority = ntohl(value->be32);
break;

case MFF_SKB_MARK:
flow->skb_mark = ntohl(value->be32);
case MFF_PKT_MARK:
flow->pkt_mark = ntohl(value->be32);
break;

CASE_MFF_REGS:
Expand Down Expand Up @@ -1607,9 +1607,9 @@ mf_set_wild(const struct mf_field *mf, struct match *match)
match->wc.masks.skb_priority = 0;
break;

case MFF_SKB_MARK:
match->flow.skb_mark = 0;
match->wc.masks.skb_mark = 0;
case MFF_PKT_MARK:
match->flow.pkt_mark = 0;
match->wc.masks.pkt_mark = 0;
break;

CASE_MFF_REGS:
Expand Down Expand Up @@ -1780,7 +1780,7 @@ mf_set(const struct mf_field *mf,
switch (mf->id) {
case MFF_IN_PORT:
case MFF_IN_PORT_OXM:
case MFF_SKB_MARK:
case MFF_PKT_MARK:
case MFF_SKB_PRIORITY:
case MFF_ETH_TYPE:
case MFF_DL_VLAN:
Expand Down Expand Up @@ -1985,7 +1985,7 @@ 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_PKT_MARK:
case MFF_SKB_PRIORITY:
CASE_MFF_REGS:
case MFF_ETH_SRC:
Expand Down
2 changes: 1 addition & 1 deletion lib/meta-flow.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ enum mf_field_id {
MFF_IN_PORT, /* be16 */
MFF_IN_PORT_OXM, /* be32 */
MFF_SKB_PRIORITY, /* be32 */
MFF_SKB_MARK, /* be32 */
MFF_PKT_MARK, /* be32 */

#if FLOW_N_REGS > 0
MFF_REG0, /* be32 */
Expand Down
2 changes: 1 addition & 1 deletion lib/odp-execute.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ odp_execute_set_action(struct ofpbuf *packet, const struct nlattr *a,
break;

case OVS_KEY_ATTR_SKB_MARK:
flow->skb_mark = nl_attr_get_u32(a);
flow->pkt_mark = nl_attr_get_u32(a);
break;

case OVS_KEY_ATTR_ETHERNET:
Expand Down
22 changes: 11 additions & 11 deletions lib/odp-util.c
Original file line number Diff line number Diff line change
Expand Up @@ -2361,7 +2361,7 @@ odp_flow_key_from_flow__(struct ofpbuf *buf, const struct flow *data,
tun_key_to_attr(buf, &data->tunnel);
}

nl_msg_put_u32(buf, OVS_KEY_ATTR_SKB_MARK, data->skb_mark);
nl_msg_put_u32(buf, OVS_KEY_ATTR_SKB_MARK, data->pkt_mark);

/* Add an ingress port attribute if this is a mask or 'odp_in_port'
* is not the magical value "ODPP_NONE". */
Expand Down Expand Up @@ -2932,7 +2932,7 @@ odp_flow_key_to_flow(const struct nlattr *key, size_t key_len,
}

if (present_attrs & (UINT64_C(1) << OVS_KEY_ATTR_SKB_MARK)) {
flow->skb_mark = nl_attr_get_u32(attrs[OVS_KEY_ATTR_SKB_MARK]);
flow->pkt_mark = nl_attr_get_u32(attrs[OVS_KEY_ATTR_SKB_MARK]);
expected_attrs |= UINT64_C(1) << OVS_KEY_ATTR_SKB_MARK;
}

Expand Down Expand Up @@ -3044,11 +3044,11 @@ commit_set_action(struct ofpbuf *odp_actions, enum ovs_key_attr key_type,
}

void
odp_put_skb_mark_action(const uint32_t skb_mark,
odp_put_pkt_mark_action(const uint32_t pkt_mark,
struct ofpbuf *odp_actions)
{
commit_set_action(odp_actions, OVS_KEY_ATTR_SKB_MARK, &skb_mark,
sizeof(skb_mark));
commit_set_action(odp_actions, OVS_KEY_ATTR_SKB_MARK, &pkt_mark,
sizeof(pkt_mark));
}

/* If any of the flow key data that ODP actions can modify are different in
Expand Down Expand Up @@ -3306,18 +3306,18 @@ commit_set_priority_action(const struct flow *flow, struct flow *base,
}

static void
commit_set_skb_mark_action(const struct flow *flow, struct flow *base,
commit_set_pkt_mark_action(const struct flow *flow, struct flow *base,
struct ofpbuf *odp_actions,
struct flow_wildcards *wc)
{
if (base->skb_mark == flow->skb_mark) {
if (base->pkt_mark == flow->pkt_mark) {
return;
}

memset(&wc->masks.skb_mark, 0xff, sizeof wc->masks.skb_mark);
base->skb_mark = flow->skb_mark;
memset(&wc->masks.pkt_mark, 0xff, sizeof wc->masks.pkt_mark);
base->pkt_mark = flow->pkt_mark;

odp_put_skb_mark_action(base->skb_mark, odp_actions);
odp_put_pkt_mark_action(base->pkt_mark, odp_actions);
}
/* If any of the flow key data that ODP actions can modify are different in
* 'base' and 'flow', appends ODP actions to 'odp_actions' that change the flow
Expand All @@ -3339,5 +3339,5 @@ commit_odp_actions(const struct flow *flow, struct flow *base,
*/
commit_mpls_action(flow, base, odp_actions, wc);
commit_set_priority_action(flow, base, odp_actions, wc);
commit_set_skb_mark_action(flow, base, odp_actions, wc);
commit_set_pkt_mark_action(flow, base, odp_actions, wc);
}
2 changes: 1 addition & 1 deletion lib/odp-util.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ size_t odp_put_userspace_action(uint32_t pid,
struct ofpbuf *odp_actions);
void odp_put_tunnel_action(const struct flow_tnl *tunnel,
struct ofpbuf *odp_actions);
void odp_put_skb_mark_action(const uint32_t skb_mark,
void odp_put_pkt_mark_action(const uint32_t pkt_mark,
struct ofpbuf *odp_actions);

/* Reasons why a subfacet might not be fast-pathable. */
Expand Down
4 changes: 2 additions & 2 deletions lib/ofp-util.c
Original file line number Diff line number Diff line change
Expand Up @@ -1134,8 +1134,8 @@ ofputil_usable_protocols(const struct match *match)
return OFPUTIL_P_NONE;
}

/* skb_mark and skb_priority can't be sent in a flow_mod */
if (wc->masks.skb_mark || wc->masks.skb_priority) {
/* pkt_mark and skb_priority can't be sent in a flow_mod */
if (wc->masks.pkt_mark || wc->masks.skb_priority) {
return OFPUTIL_P_NONE;
}

Expand Down
2 changes: 1 addition & 1 deletion ofproto/ofproto-dpif-upcall.c
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ handle_miss_upcalls(struct udpif *udpif, struct list *upcalls)
continue;
}

flow_extract(dupcall->packet, flow.skb_priority, flow.skb_mark,
flow_extract(dupcall->packet, flow.skb_priority, flow.pkt_mark,
&flow.tunnel, &flow.in_port, &miss->flow);

/* Add other packets to a to-do list. */
Expand Down
14 changes: 7 additions & 7 deletions ofproto/ofproto-dpif-xlate.c
Original file line number Diff line number Diff line change
Expand Up @@ -1519,7 +1519,7 @@ compose_output_action__(struct xlate_ctx *ctx, ofp_port_t ofp_port,
struct flow_wildcards *wc = &ctx->xout->wc;
struct flow *flow = &ctx->xin->flow;
ovs_be16 flow_vlan_tci;
uint32_t flow_skb_mark;
uint32_t flow_pkt_mark;
uint8_t flow_nw_tos;
odp_port_t out_port, odp_port;
uint8_t dscp;
Expand Down Expand Up @@ -1587,7 +1587,7 @@ compose_output_action__(struct xlate_ctx *ctx, ofp_port_t ofp_port,
}

flow_vlan_tci = flow->vlan_tci;
flow_skb_mark = flow->skb_mark;
flow_pkt_mark = flow->pkt_mark;
flow_nw_tos = flow->nw_tos;

if (dscp_from_skb_priority(xport, flow->skb_priority, &dscp)) {
Expand Down Expand Up @@ -1633,7 +1633,7 @@ compose_output_action__(struct xlate_ctx *ctx, ofp_port_t ofp_port,
out_port = ofp_port_to_odp_port(ctx->xbridge, vlandev_port);
flow->vlan_tci = htons(0);
}
flow->skb_mark &= ~IPSEC_MARK;
flow->pkt_mark &= ~IPSEC_MARK;
}

if (out_port != ODPP_NONE) {
Expand All @@ -1650,7 +1650,7 @@ compose_output_action__(struct xlate_ctx *ctx, ofp_port_t ofp_port,
out:
/* Restore flow */
flow->vlan_tci = flow_vlan_tci;
flow->skb_mark = flow_skb_mark;
flow->pkt_mark = flow_pkt_mark;
flow->nw_tos = flow_nw_tos;
}

Expand Down Expand Up @@ -1785,7 +1785,7 @@ execute_controller_action(struct xlate_ctx *ctx, int len,
packet = ofpbuf_clone(ctx->xin->packet);

key.skb_priority = 0;
key.skb_mark = 0;
key.pkt_mark = 0;
memset(&key.tunnel, 0, sizeof key.tunnel);

commit_odp_actions(&ctx->xin->flow, &ctx->base_flow,
Expand Down Expand Up @@ -2609,9 +2609,9 @@ xlate_actions(struct xlate_in *xin, struct xlate_out *xout)

if (tnl_port_should_receive(&ctx.xin->flow)) {
memset(&wc->masks.tunnel, 0xff, sizeof wc->masks.tunnel);
/* skb_mark is currently used only by tunnels but that will likely
/* pkt_mark is currently used only by tunnels but that will likely
* change in the future. */
memset(&wc->masks.skb_mark, 0xff, sizeof wc->masks.skb_mark);
memset(&wc->masks.pkt_mark, 0xff, sizeof wc->masks.pkt_mark);
}
if (ctx.xbridge->has_netflow) {
netflow_mask_wc(flow, wc);
Expand Down
2 changes: 1 addition & 1 deletion ofproto/ofproto-dpif.c
Original file line number Diff line number Diff line change
Expand Up @@ -5413,7 +5413,7 @@ ofproto_unixctl_trace(struct unixctl_conn *conn, int argc, const char *argv[],

/* Use the metadata from the flow and the packet argument
* to reconstruct the flow. */
flow_extract(packet, flow.skb_priority, flow.skb_mark, NULL,
flow_extract(packet, flow.skb_priority, flow.pkt_mark, NULL,
&in_port_, &flow);
}
}
Expand Down
4 changes: 2 additions & 2 deletions ofproto/ofproto-unixctl.man
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ only metadata. The metadata can be:
.RS
.IP \fIskb_priority\fR
Packet QoS priority.
.IP \fIskb_mark\fR
SKB mark of the packet.
.IP \fIpkt_mark\fR
Mark of the packet.
.IP \fItun_id\fR
The tunnel ID on which the packet arrived.
.IP \fIin_port\fR
Expand Down
Loading

0 comments on commit 1362e24

Please sign in to comment.