Skip to content

Commit

Permalink
datapath: s/ODPAT_/ODP_ACTION_ATTR_/ to fit new naming scheme.
Browse files Browse the repository at this point in the history
Jesse suggested this naming scheme, so I'm adjusting existing names to
fit it.

Signed-off-by: Ben Pfaff <[email protected]>
Acked-by: Jesse Gross <[email protected]>
  • Loading branch information
blp committed Jan 28, 2011
1 parent 3d8c953 commit 7aec165
Show file tree
Hide file tree
Showing 12 changed files with 193 additions and 186 deletions.
34 changes: 17 additions & 17 deletions datapath/actions.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ static struct sk_buff *set_nw_addr(struct sk_buff *skb,
return NULL;

nh = ip_hdr(skb);
nwaddr = nla_type(a) == ODPAT_SET_NW_SRC ? &nh->saddr : &nh->daddr;
nwaddr = nla_type(a) == ODP_ACTION_ATTR_SET_NW_SRC ? &nh->saddr : &nh->daddr;

check = get_l4_checksum(skb, key);
if (likely(check))
Expand Down Expand Up @@ -306,7 +306,7 @@ static struct sk_buff *set_tp_port(struct sk_buff *skb,
* supports those protocols.
*/
th = udp_hdr(skb);
port = nla_type(a) == ODPAT_SET_TP_SRC ? &th->source : &th->dest;
port = nla_type(a) == ODP_ACTION_ATTR_SET_TP_SRC ? &th->source : &th->dest;
inet_proto_csum_replace2(check, skb, *port, nla_get_be16(a), 0);
*port = nla_get_be16(a);

Expand Down Expand Up @@ -399,69 +399,69 @@ static int do_execute_actions(struct datapath *dp, struct sk_buff *skb,
}

switch (nla_type(a)) {
case ODPAT_OUTPUT:
case ODP_ACTION_ATTR_OUTPUT:
prev_port = nla_get_u32(a);
break;

case ODPAT_CONTROLLER:
case ODP_ACTION_ATTR_CONTROLLER:
err = output_control(dp, skb, nla_get_u64(a), key);
if (err) {
kfree_skb(skb);
return err;
}
break;

case ODPAT_SET_TUNNEL:
case ODP_ACTION_ATTR_SET_TUNNEL:
OVS_CB(skb)->tun_id = nla_get_be64(a);
break;

case ODPAT_SET_DL_TCI:
case ODP_ACTION_ATTR_SET_DL_TCI:
skb = modify_vlan_tci(dp, skb, key, a, rem);
if (IS_ERR(skb))
return PTR_ERR(skb);
break;

case ODPAT_STRIP_VLAN:
case ODP_ACTION_ATTR_STRIP_VLAN:
skb = strip_vlan(skb);
break;

case ODPAT_SET_DL_SRC:
case ODP_ACTION_ATTR_SET_DL_SRC:
skb = make_writable(skb, 0);
if (!skb)
return -ENOMEM;
memcpy(eth_hdr(skb)->h_source, nla_data(a), ETH_ALEN);
break;

case ODPAT_SET_DL_DST:
case ODP_ACTION_ATTR_SET_DL_DST:
skb = make_writable(skb, 0);
if (!skb)
return -ENOMEM;
memcpy(eth_hdr(skb)->h_dest, nla_data(a), ETH_ALEN);
break;

case ODPAT_SET_NW_SRC:
case ODPAT_SET_NW_DST:
case ODP_ACTION_ATTR_SET_NW_SRC:
case ODP_ACTION_ATTR_SET_NW_DST:
skb = set_nw_addr(skb, key, a);
break;

case ODPAT_SET_NW_TOS:
case ODP_ACTION_ATTR_SET_NW_TOS:
skb = set_nw_tos(skb, key, nla_get_u8(a));
break;

case ODPAT_SET_TP_SRC:
case ODPAT_SET_TP_DST:
case ODP_ACTION_ATTR_SET_TP_SRC:
case ODP_ACTION_ATTR_SET_TP_DST:
skb = set_tp_port(skb, key, a);
break;

case ODPAT_SET_PRIORITY:
case ODP_ACTION_ATTR_SET_PRIORITY:
skb->priority = nla_get_u32(a);
break;

case ODPAT_POP_PRIORITY:
case ODP_ACTION_ATTR_POP_PRIORITY:
skb->priority = priority;
break;

case ODPAT_DROP_SPOOFED_ARP:
case ODP_ACTION_ATTR_DROP_SPOOFED_ARP:
if (unlikely(is_spoofed_arp(skb, key)))
goto exit;
break;
Expand Down
66 changes: 33 additions & 33 deletions datapath/datapath.c
Original file line number Diff line number Diff line change
Expand Up @@ -570,58 +570,58 @@ static int validate_actions(const struct nlattr *attr)
int rem;

nla_for_each_nested(a, attr, rem) {
static const u32 action_lens[ODPAT_MAX + 1] = {
[ODPAT_OUTPUT] = 4,
[ODPAT_CONTROLLER] = 8,
[ODPAT_SET_DL_TCI] = 2,
[ODPAT_STRIP_VLAN] = 0,
[ODPAT_SET_DL_SRC] = ETH_ALEN,
[ODPAT_SET_DL_DST] = ETH_ALEN,
[ODPAT_SET_NW_SRC] = 4,
[ODPAT_SET_NW_DST] = 4,
[ODPAT_SET_NW_TOS] = 1,
[ODPAT_SET_TP_SRC] = 2,
[ODPAT_SET_TP_DST] = 2,
[ODPAT_SET_TUNNEL] = 8,
[ODPAT_SET_PRIORITY] = 4,
[ODPAT_POP_PRIORITY] = 0,
[ODPAT_DROP_SPOOFED_ARP] = 0,
static const u32 action_lens[ODP_ACTION_ATTR_MAX + 1] = {
[ODP_ACTION_ATTR_OUTPUT] = 4,
[ODP_ACTION_ATTR_CONTROLLER] = 8,
[ODP_ACTION_ATTR_SET_DL_TCI] = 2,
[ODP_ACTION_ATTR_STRIP_VLAN] = 0,
[ODP_ACTION_ATTR_SET_DL_SRC] = ETH_ALEN,
[ODP_ACTION_ATTR_SET_DL_DST] = ETH_ALEN,
[ODP_ACTION_ATTR_SET_NW_SRC] = 4,
[ODP_ACTION_ATTR_SET_NW_DST] = 4,
[ODP_ACTION_ATTR_SET_NW_TOS] = 1,
[ODP_ACTION_ATTR_SET_TP_SRC] = 2,
[ODP_ACTION_ATTR_SET_TP_DST] = 2,
[ODP_ACTION_ATTR_SET_TUNNEL] = 8,
[ODP_ACTION_ATTR_SET_PRIORITY] = 4,
[ODP_ACTION_ATTR_POP_PRIORITY] = 0,
[ODP_ACTION_ATTR_DROP_SPOOFED_ARP] = 0,
};
int type = nla_type(a);

if (type > ODPAT_MAX || nla_len(a) != action_lens[type])
if (type > ODP_ACTION_ATTR_MAX || nla_len(a) != action_lens[type])
return -EINVAL;

switch (type) {
case ODPAT_UNSPEC:
case ODP_ACTION_ATTR_UNSPEC:
return -EINVAL;

case ODPAT_CONTROLLER:
case ODPAT_STRIP_VLAN:
case ODPAT_SET_DL_SRC:
case ODPAT_SET_DL_DST:
case ODPAT_SET_NW_SRC:
case ODPAT_SET_NW_DST:
case ODPAT_SET_TP_SRC:
case ODPAT_SET_TP_DST:
case ODPAT_SET_TUNNEL:
case ODPAT_SET_PRIORITY:
case ODPAT_POP_PRIORITY:
case ODPAT_DROP_SPOOFED_ARP:
case ODP_ACTION_ATTR_CONTROLLER:
case ODP_ACTION_ATTR_STRIP_VLAN:
case ODP_ACTION_ATTR_SET_DL_SRC:
case ODP_ACTION_ATTR_SET_DL_DST:
case ODP_ACTION_ATTR_SET_NW_SRC:
case ODP_ACTION_ATTR_SET_NW_DST:
case ODP_ACTION_ATTR_SET_TP_SRC:
case ODP_ACTION_ATTR_SET_TP_DST:
case ODP_ACTION_ATTR_SET_TUNNEL:
case ODP_ACTION_ATTR_SET_PRIORITY:
case ODP_ACTION_ATTR_POP_PRIORITY:
case ODP_ACTION_ATTR_DROP_SPOOFED_ARP:
/* No validation needed. */
break;

case ODPAT_OUTPUT:
case ODP_ACTION_ATTR_OUTPUT:
if (nla_get_u32(a) >= DP_MAX_PORTS)
return -EINVAL;
break;

case ODPAT_SET_DL_TCI:
case ODP_ACTION_ATTR_SET_DL_TCI:
if (nla_get_be16(a) & htons(VLAN_CFI_MASK))
return -EINVAL;
break;

case ODPAT_SET_NW_TOS:
case ODP_ACTION_ATTR_SET_NW_TOS:
if (nla_get_u8(a) & INET_ECN_MASK)
return -EINVAL;
break;
Expand Down
54 changes: 28 additions & 26 deletions include/openvswitch/datapath-protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ enum odp_packet_cmd {

/* Kernel-to-user notifications. */
ODP_PACKET_CMD_MISS, /* Flow table miss. */
ODP_PACKET_CMD_ACTION, /* ODPAT_CONTROLLER action. */
ODP_PACKET_CMD_ACTION, /* ODP_ACTION_ATTR_CONTROLLER action. */
ODP_PACKET_CMD_SAMPLE, /* Sampled packet. */

/* User commands. */
Expand All @@ -173,18 +173,20 @@ enum odp_packet_cmd {
* @ODP_PACKET_ATTR_PACKET: Present for all notifications. Contains the entire
* packet as received, from the start of the Ethernet header onward. For
* %ODP_PACKET_CMD_ACTION, %ODP_PACKET_ATTR_PACKET reflects changes made by
* actions preceding %ODPAT_CONTROLLER, but %ODP_PACKET_ATTR_KEY is the flow
* key extracted from the packet as originally received.
* actions preceding %ODP_ACTION_ATTR_CONTROLLER, but %ODP_PACKET_ATTR_KEY is
* the flow key extracted from the packet as originally received.
* @ODP_PACKET_ATTR_KEY: Present for all notifications. Contains the flow key
* extracted from the packet as nested %ODP_KEY_ATTR_* attributes. This allows
* userspace to adapt its flow setup strategy by comparing its notion of the
* flow key against the kernel's.
* @ODP_PACKET_ATTR_USERDATA: Present for an %ODP_PACKET_CMD_ACTION
* notification if the %ODPAT_CONTROLLER action's argument was nonzero.
* notification if the %ODP_ACTION_ATTR_CONTROLLER, action's argument was
* nonzero.
* @ODP_PACKET_ATTR_SAMPLE_POOL: Present for %ODP_PACKET_CMD_SAMPLE. Contains
* the number of packets processed so far that were candidates for sampling.
* @ODP_PACKET_ATTR_ACTIONS: Present for %ODP_PACKET_CMD_SAMPLE. Contains a
* copy of the actions applied to the packet, as nested %ODPAT_* attributes.
* copy of the actions applied to the packet, as nested %ODP_ACTION_ATTR_*
* attributes.
*
* These attributes follow the &struct odp_header within the Generic Netlink
* payload for %ODP_PACKET_* commands.
Expand All @@ -193,9 +195,9 @@ enum odp_packet_attr {
ODP_PACKET_ATTR_UNSPEC,
ODP_PACKET_ATTR_PACKET, /* Packet data. */
ODP_PACKET_ATTR_KEY, /* Nested ODP_KEY_ATTR_* attributes. */
ODP_PACKET_ATTR_USERDATA, /* 64-bit data from ODPAT_CONTROLLER. */
ODP_PACKET_ATTR_USERDATA, /* u64 ODP_ACTION_ATTR_CONTROLLER arg. */
ODP_PACKET_ATTR_SAMPLE_POOL, /* # sampling candidate packets so far. */
ODP_PACKET_ATTR_ACTIONS, /* Nested ODPAT_* attributes. */
ODP_PACKET_ATTR_ACTIONS, /* Nested ODP_ACTION_ATTR_* attributes. */
__ODP_PACKET_ATTR_MAX
};

Expand Down Expand Up @@ -385,7 +387,7 @@ struct odp_key_arp {
enum odp_flow_attr {
ODP_FLOW_ATTR_UNSPEC,
ODP_FLOW_ATTR_KEY, /* Sequence of ODP_KEY_ATTR_* attributes. */
ODP_FLOW_ATTR_ACTIONS, /* Sequence of nested ODPAT_* attributes. */
ODP_FLOW_ATTR_ACTIONS, /* Nested ODP_ACTION_ATTR_* attributes. */
ODP_FLOW_ATTR_STATS, /* struct odp_flow_stats. */
ODP_FLOW_ATTR_TCP_FLAGS, /* 8-bit OR'd TCP flags. */
ODP_FLOW_ATTR_USED, /* u64 msecs last used in monotonic time. */
Expand All @@ -397,25 +399,25 @@ enum odp_flow_attr {

/* Action types. */
enum odp_action_type {
ODPAT_UNSPEC,
ODPAT_OUTPUT, /* Output to switch port. */
ODPAT_CONTROLLER, /* Send copy to controller. */
ODPAT_SET_DL_TCI, /* Set the 802.1q TCI value. */
ODPAT_STRIP_VLAN, /* Strip the 802.1q header. */
ODPAT_SET_DL_SRC, /* Ethernet source address. */
ODPAT_SET_DL_DST, /* Ethernet destination address. */
ODPAT_SET_NW_SRC, /* IPv4 source address. */
ODPAT_SET_NW_DST, /* IPv4 destination address. */
ODPAT_SET_NW_TOS, /* IP ToS/DSCP field (6 bits). */
ODPAT_SET_TP_SRC, /* TCP/UDP source port. */
ODPAT_SET_TP_DST, /* TCP/UDP destination port. */
ODPAT_SET_TUNNEL, /* Set the encapsulating tunnel ID. */
ODPAT_SET_PRIORITY, /* Set skb->priority. */
ODPAT_POP_PRIORITY, /* Restore original skb->priority. */
ODPAT_DROP_SPOOFED_ARP, /* Drop ARPs with spoofed source MAC. */
__ODPAT_MAX
ODP_ACTION_ATTR_UNSPEC,
ODP_ACTION_ATTR_OUTPUT, /* Output to switch port. */
ODP_ACTION_ATTR_CONTROLLER, /* Send copy to controller. */
ODP_ACTION_ATTR_SET_DL_TCI, /* Set the 802.1q TCI value. */
ODP_ACTION_ATTR_STRIP_VLAN, /* Strip the 802.1q header. */
ODP_ACTION_ATTR_SET_DL_SRC, /* Ethernet source address. */
ODP_ACTION_ATTR_SET_DL_DST, /* Ethernet destination address. */
ODP_ACTION_ATTR_SET_NW_SRC, /* IPv4 source address. */
ODP_ACTION_ATTR_SET_NW_DST, /* IPv4 destination address. */
ODP_ACTION_ATTR_SET_NW_TOS, /* IP ToS/DSCP field (6 bits). */
ODP_ACTION_ATTR_SET_TP_SRC, /* TCP/UDP source port. */
ODP_ACTION_ATTR_SET_TP_DST, /* TCP/UDP destination port. */
ODP_ACTION_ATTR_SET_TUNNEL, /* Set the encapsulating tunnel ID. */
ODP_ACTION_ATTR_SET_PRIORITY, /* Set skb->priority. */
ODP_ACTION_ATTR_POP_PRIORITY, /* Restore original skb->priority. */
ODP_ACTION_ATTR_DROP_SPOOFED_ARP, /* Drop ARPs with spoofed source MAC. */
__ODP_ACTION_ATTR_MAX
};

#define ODPAT_MAX (__ODPAT_MAX - 1)
#define ODP_ACTION_ATTR_MAX (__ODP_ACTION_ATTR_MAX - 1)

#endif /* openvswitch/datapath-protocol.h */
Loading

0 comments on commit 7aec165

Please sign in to comment.