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))
* 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);
}
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);
}
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;
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;
/* 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. */
* @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.
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
};
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. */
/* 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 */
}
switch (type) {
- case ODPAT_OUTPUT:
+ case ODP_ACTION_ATTR_OUTPUT:
if (nl_attr_get_u32(a) >= MAX_PORTS) {
return EINVAL;
}
break;
- case ODPAT_CONTROLLER:
- case ODPAT_DROP_SPOOFED_ARP:
+ case ODP_ACTION_ATTR_CONTROLLER:
+ case ODP_ACTION_ATTR_DROP_SPOOFED_ARP:
break;
- case ODPAT_SET_DL_TCI:
+ case ODP_ACTION_ATTR_SET_DL_TCI:
*mutates = true;
if (nl_attr_get_be16(a) & htons(VLAN_CFI)) {
return EINVAL;
}
break;
- case ODPAT_SET_NW_TOS:
+ case ODP_ACTION_ATTR_SET_NW_TOS:
*mutates = true;
if (nl_attr_get_u8(a) & IP_ECN_MASK) {
return EINVAL;
}
break;
- 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 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:
*mutates = true;
break;
- case ODPAT_SET_TUNNEL:
- case ODPAT_SET_PRIORITY:
- case ODPAT_POP_PRIORITY:
+ case ODP_ACTION_ATTR_SET_TUNNEL:
+ case ODP_ACTION_ATTR_SET_PRIORITY:
+ case ODP_ACTION_ATTR_POP_PRIORITY:
default:
return EOPNOTSUPP;
}
uint16_t type = nl_attr_type(a);
uint32_t *field;
- field = type == ODPAT_SET_NW_SRC ? &nh->ip_src : &nh->ip_dst;
+ field = type == ODP_ACTION_ATTR_SET_NW_SRC ? &nh->ip_src : &nh->ip_dst;
if (key->nw_proto == IP_TYPE_TCP && packet->l7) {
struct tcp_header *th = packet->l4;
th->tcp_csum = recalc_csum32(th->tcp_csum, *field, ip);
if (key->nw_proto == IPPROTO_TCP && packet->l7) {
struct tcp_header *th = packet->l4;
- field = type == ODPAT_SET_TP_SRC ? &th->tcp_src : &th->tcp_dst;
+ field = (type == ODP_ACTION_ATTR_SET_TP_SRC
+ ? &th->tcp_src : &th->tcp_dst);
th->tcp_csum = recalc_csum16(th->tcp_csum, *field, port);
*field = port;
} else if (key->nw_proto == IPPROTO_UDP && packet->l7) {
struct udp_header *uh = packet->l4;
- field = type == ODPAT_SET_TP_SRC ? &uh->udp_src : &uh->udp_dst;
+ field = (type == ODP_ACTION_ATTR_SET_TP_SRC
+ ? &uh->udp_src : &uh->udp_dst);
uh->udp_csum = recalc_csum16(uh->udp_csum, *field, port);
*field = port;
} else {
NL_ATTR_FOR_EACH_UNSAFE (a, left, actions, actions_len) {
switch (nl_attr_type(a)) {
- case ODPAT_OUTPUT:
+ case ODP_ACTION_ATTR_OUTPUT:
dp_netdev_output_port(dp, packet, nl_attr_get_u32(a));
break;
- case ODPAT_CONTROLLER:
+ case ODP_ACTION_ATTR_CONTROLLER:
dp_netdev_output_control(dp, packet, DPIF_UC_ACTION,
key, nl_attr_get_u64(a));
break;
- case ODPAT_SET_DL_TCI:
+ case ODP_ACTION_ATTR_SET_DL_TCI:
dp_netdev_set_dl_tci(packet, nl_attr_get_be16(a));
break;
- case ODPAT_STRIP_VLAN:
+ case ODP_ACTION_ATTR_STRIP_VLAN:
dp_netdev_strip_vlan(packet);
break;
- case ODPAT_SET_DL_SRC:
+ case ODP_ACTION_ATTR_SET_DL_SRC:
dp_netdev_set_dl_src(packet, nl_attr_get_unspec(a, ETH_ADDR_LEN));
break;
- case ODPAT_SET_DL_DST:
+ case ODP_ACTION_ATTR_SET_DL_DST:
dp_netdev_set_dl_dst(packet, nl_attr_get_unspec(a, ETH_ADDR_LEN));
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:
dp_netdev_set_nw_addr(packet, key, a);
break;
- case ODPAT_SET_NW_TOS:
+ case ODP_ACTION_ATTR_SET_NW_TOS:
dp_netdev_set_nw_tos(packet, key, nl_attr_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:
dp_netdev_set_tp_port(packet, key, a);
break;
- case ODPAT_DROP_SPOOFED_ARP:
+ case ODP_ACTION_ATTR_DROP_SPOOFED_ARP:
if (dp_netdev_is_spoofed_arp(packet, key)) {
return 0;
}
/* Adds or modifies a flow in 'dpif'. The flow is specified by the Netlink
* attributes with types ODP_KEY_ATTR_* in the 'key_len' bytes starting at
* 'key'. The associated actions are specified by the Netlink attributes
- * with types ODPAT_* in the 'actions_len' bytes starting at 'actions'.
+ * with types ODP_ACTION_ATTR_* in the 'actions_len' bytes starting at
+ * 'actions'.
*
* - If the flow's key does not exist in 'dpif', then the flow will be
* added if 'flags' includes DPIF_FP_CREATE. Otherwise the operation
* On success, if 'key' and 'key_len' are nonnull then '*key' and
* '*key_len' must be set to Netlink attributes with types ODP_KEY_ATTR_*
* representing the dumped flow's key. If 'actions' and 'actions_len' are
- * nonnull then they should be set to Netlink attributes with types ODPAT_*
- * representing the dumped flow's actions. If 'stats' is nonnull then it
- * should be set to the dumped flow's statistics.
+ * nonnull then they should be set to Netlink attributes with types
+ * ODP_ACTION_ATTR_* representing the dumped flow's actions. If 'stats'
+ * is nonnull then it should be set to the dumped flow's statistics.
*
* All of the returned data is owned by 'dpif', not by the caller, and the
* caller must not modify or free it. 'dpif' must guarantee that it
int (*set_sflow_probability)(struct dpif *dpif, uint32_t probability);
/* Translates OpenFlow queue ID 'queue_id' (in host byte order) into a
- * priority value for use in the ODPAT_SET_PRIORITY action in
+ * priority value for use in the ODP_ACTION_ATTR_SET_PRIORITY action in
* '*priority'. */
int (*queue_to_priority)(const struct dpif *dpif, uint32_t queue_id,
uint32_t *priority);
/* Adds or modifies a flow in 'dpif'. The flow is specified by the Netlink
* attributes with types ODP_KEY_ATTR_* in the 'key_len' bytes starting at
* 'key'. The associated actions are specified by the Netlink attributes with
- * types ODPAT_* in the 'actions_len' bytes starting at 'actions'.
+ * types ODP_ACTION_ATTR_* in the 'actions_len' bytes starting at 'actions'.
*
* - If the flow's key does not exist in 'dpif', then the flow will be added if
* 'flags' includes DPIF_FP_CREATE. Otherwise the operation will fail with
* On success, if 'key' and 'key_len' are nonnull then '*key' and '*key_len'
* will be set to Netlink attributes with types ODP_KEY_ATTR_* representing the
* dumped flow's key. If 'actions' and 'actions_len' are nonnull then they are
- * set to Netlink attributes with types ODPAT_* representing the dumped flow's
- * actions. If 'stats' is nonnull then it will be set to the dumped flow's
- * statistics.
+ * set to Netlink attributes with types ODP_ACTION_ATTR_* representing the
+ * dumped flow's actions. If 'stats' is nonnull then it will be set to the
+ * dumped flow's statistics.
*
* All of the returned data is owned by 'dpif', not by the caller, and the
* caller must not modify or free it. 'dpif' guarantees that it remains
}
/* Translates OpenFlow queue ID 'queue_id' (in host byte order) into a priority
- * value for use in the ODPAT_SET_PRIORITY action. On success, returns 0 and
- * stores the priority into '*priority'. On failure, returns a positive errno
- * value and stores 0 into '*priority'. */
+ * value for use in the ODP_ACTION_ATTR_SET_PRIORITY action. On success,
+ * returns 0 and stores the priority into '*priority'. On failure, returns a
+ * positive errno value and stores 0 into '*priority'. */
int
dpif_queue_to_priority(const struct dpif *dpif, uint32_t queue_id,
uint32_t *priority)
enum dpif_upcall_type {
DPIF_UC_MISS, /* Miss in flow table. */
- DPIF_UC_ACTION, /* ODPAT_CONTROLLER action. */
+ DPIF_UC_ACTION, /* ODP_ACTION_ATTR_CONTROLLER action. */
DPIF_UC_SAMPLE, /* Packet sampling. */
DPIF_N_UC_TYPES
};
size_t key_len; /* Length of 'key' in bytes. */
/* DPIF_UC_ACTION only. */
- uint64_t userdata; /* Argument to ODPAT_CONTROLLER. */
+ uint64_t userdata; /* Argument to ODP_ACTION_ATTR_CONTROLLER. */
/* DPIF_UC_SAMPLE only. */
uint32_t sample_pool; /* # of sampling candidate packets so far. */
int
odp_action_len(uint16_t type)
{
- if (type > ODPAT_MAX) {
+ if (type > ODP_ACTION_ATTR_MAX) {
return -1;
}
switch ((enum odp_action_type) type) {
- case ODPAT_OUTPUT: return 4;
- case ODPAT_CONTROLLER: return 8;
- case ODPAT_SET_DL_TCI: return 2;
- case ODPAT_STRIP_VLAN: return 0;
- case ODPAT_SET_DL_SRC: return ETH_ADDR_LEN;
- case ODPAT_SET_DL_DST: return ETH_ADDR_LEN;
- case ODPAT_SET_NW_SRC: return 4;
- case ODPAT_SET_NW_DST: return 4;
- case ODPAT_SET_NW_TOS: return 1;
- case ODPAT_SET_TP_SRC: return 2;
- case ODPAT_SET_TP_DST: return 2;
- case ODPAT_SET_TUNNEL: return 8;
- case ODPAT_SET_PRIORITY: return 4;
- case ODPAT_POP_PRIORITY: return 0;
- case ODPAT_DROP_SPOOFED_ARP: return 0;
-
- case ODPAT_UNSPEC:
- case __ODPAT_MAX:
+ case ODP_ACTION_ATTR_OUTPUT: return 4;
+ case ODP_ACTION_ATTR_CONTROLLER: return 8;
+ case ODP_ACTION_ATTR_SET_DL_TCI: return 2;
+ case ODP_ACTION_ATTR_STRIP_VLAN: return 0;
+ case ODP_ACTION_ATTR_SET_DL_SRC: return ETH_ADDR_LEN;
+ case ODP_ACTION_ATTR_SET_DL_DST: return ETH_ADDR_LEN;
+ case ODP_ACTION_ATTR_SET_NW_SRC: return 4;
+ case ODP_ACTION_ATTR_SET_NW_DST: return 4;
+ case ODP_ACTION_ATTR_SET_NW_TOS: return 1;
+ case ODP_ACTION_ATTR_SET_TP_SRC: return 2;
+ case ODP_ACTION_ATTR_SET_TP_DST: return 2;
+ case ODP_ACTION_ATTR_SET_TUNNEL: return 8;
+ case ODP_ACTION_ATTR_SET_PRIORITY: return 4;
+ case ODP_ACTION_ATTR_POP_PRIORITY: return 0;
+ case ODP_ACTION_ATTR_DROP_SPOOFED_ARP: return 0;
+
+ case ODP_ACTION_ATTR_UNSPEC:
+ case __ODP_ACTION_ATTR_MAX:
return -1;
}
}
switch (nl_attr_type(a)) {
- case ODPAT_OUTPUT:
+ case ODP_ACTION_ATTR_OUTPUT:
ds_put_format(ds, "%"PRIu16, nl_attr_get_u32(a));
break;
- case ODPAT_CONTROLLER:
+ case ODP_ACTION_ATTR_CONTROLLER:
ds_put_format(ds, "ctl(%"PRIu64")", nl_attr_get_u64(a));
break;
- case ODPAT_SET_TUNNEL:
+ case ODP_ACTION_ATTR_SET_TUNNEL:
ds_put_format(ds, "set_tunnel(%#"PRIx64")",
ntohll(nl_attr_get_be64(a)));
break;
- case ODPAT_SET_DL_TCI:
+ case ODP_ACTION_ATTR_SET_DL_TCI:
ds_put_format(ds, "set_tci(vid=%"PRIu16",pcp=%d)",
vlan_tci_to_vid(nl_attr_get_be16(a)),
vlan_tci_to_pcp(nl_attr_get_be16(a)));
break;
- case ODPAT_STRIP_VLAN:
+ case ODP_ACTION_ATTR_STRIP_VLAN:
ds_put_format(ds, "strip_vlan");
break;
- case ODPAT_SET_DL_SRC:
+ case ODP_ACTION_ATTR_SET_DL_SRC:
eth = nl_attr_get_unspec(a, ETH_ADDR_LEN);
ds_put_format(ds, "set_dl_src("ETH_ADDR_FMT")", ETH_ADDR_ARGS(eth));
break;
- case ODPAT_SET_DL_DST:
+ case ODP_ACTION_ATTR_SET_DL_DST:
eth = nl_attr_get_unspec(a, ETH_ADDR_LEN);
ds_put_format(ds, "set_dl_dst("ETH_ADDR_FMT")", ETH_ADDR_ARGS(eth));
break;
- case ODPAT_SET_NW_SRC:
+ case ODP_ACTION_ATTR_SET_NW_SRC:
ip = nl_attr_get_be32(a);
ds_put_format(ds, "set_nw_src("IP_FMT")", IP_ARGS(&ip));
break;
- case ODPAT_SET_NW_DST:
+ case ODP_ACTION_ATTR_SET_NW_DST:
ip = nl_attr_get_be32(a);
ds_put_format(ds, "set_nw_dst("IP_FMT")", IP_ARGS(&ip));
break;
- case ODPAT_SET_NW_TOS:
+ case ODP_ACTION_ATTR_SET_NW_TOS:
ds_put_format(ds, "set_nw_tos(%"PRIu8")", nl_attr_get_u8(a));
break;
- case ODPAT_SET_TP_SRC:
+ case ODP_ACTION_ATTR_SET_TP_SRC:
ds_put_format(ds, "set_tp_src(%"PRIu16")", ntohs(nl_attr_get_be16(a)));
break;
- case ODPAT_SET_TP_DST:
+ case ODP_ACTION_ATTR_SET_TP_DST:
ds_put_format(ds, "set_tp_dst(%"PRIu16")", ntohs(nl_attr_get_be16(a)));
break;
- case ODPAT_SET_PRIORITY:
+ case ODP_ACTION_ATTR_SET_PRIORITY:
ds_put_format(ds, "set_priority(%#"PRIx32")", nl_attr_get_u32(a));
break;
- case ODPAT_POP_PRIORITY:
+ case ODP_ACTION_ATTR_POP_PRIORITY:
ds_put_cstr(ds, "pop_priority");
break;
- case ODPAT_DROP_SPOOFED_ARP:
+ case ODP_ACTION_ATTR_DROP_SPOOFED_ARP:
ds_put_cstr(ds, "drop_spoofed_arp");
break;
default:
/*
- * Copyright (c) 2008, 2009, 2010 Nicira Networks.
+ * Copyright (c) 2008, 2009, 2010, 2011 Nicira Networks.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
unsigned int left;
NL_ATTR_FOR_EACH_UNSAFE (a, left, actions, actions_len) {
- if (nl_attr_type(a) == ODPAT_OUTPUT
+ if (nl_attr_type(a) == ODP_ACTION_ATTR_OUTPUT
&& nl_attr_get_u32(a) == ODPP_LOCAL) {
return true;
}
/*
- * Copyright (c) 2009, 2010 Nicira Networks.
+ * Copyright (c) 2009, 2010, 2011 Nicira Networks.
* Copyright (c) 2009 InMon Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
ovs_be16 tci;
switch (nl_attr_type(a)) {
- case ODPAT_OUTPUT:
+ case ODP_ACTION_ATTR_OUTPUT:
fs.output = ofproto_sflow_odp_port_to_ifindex(os,
nl_attr_get_u32(a));
n_outputs++;
break;
- case ODPAT_SET_DL_TCI:
+ case ODP_ACTION_ATTR_SET_DL_TCI:
tci = nl_attr_get_be16(a);
switchElem.flowType.sw.dst_vlan = vlan_tci_to_vid(tci);
switchElem.flowType.sw.dst_priority = vlan_tci_to_pcp(tci);
int recurse; /* Recursion level, via xlate_table_action. */
int last_pop_priority; /* Offset in 'odp_actions' just past most
- * recently added ODPAT_SET_PRIORITY. */
+ * recent ODP_ACTION_ATTR_SET_PRIORITY. */
};
static void action_xlate_ctx_init(struct action_xlate_ctx *,
struct ofpbuf *packet)
{
if (actions_len == NLA_ALIGN(NLA_HDRLEN + sizeof(uint64_t))
- && odp_actions->nla_type == ODPAT_CONTROLLER) {
+ && odp_actions->nla_type == ODP_ACTION_ATTR_CONTROLLER) {
/* As an optimization, avoid a round-trip from userspace to kernel to
* userspace. This also avoids possibly filling up kernel packet
* buffers along the way. */
*/
}
- nl_msg_put_u32(ctx->odp_actions, ODPAT_OUTPUT, port);
+ nl_msg_put_u32(ctx->odp_actions, ODP_ACTION_ATTR_OUTPUT, port);
ctx->nf_output_iface = port;
}
HMAP_FOR_EACH (ofport, hmap_node, &ofproto->ports) {
uint16_t odp_port = ofport->odp_port;
if (odp_port != odp_in_port && !(ofport->opp.config & mask)) {
- nl_msg_put_u32(odp_actions, ODPAT_OUTPUT, odp_port);
+ nl_msg_put_u32(odp_actions, ODP_ACTION_ATTR_OUTPUT, odp_port);
}
}
*nf_output_iface = NF_OUT_FLOOD;
&ctx->nf_output_iface, ctx->odp_actions);
break;
case OFPP_CONTROLLER:
- nl_msg_put_u64(ctx->odp_actions, ODPAT_CONTROLLER, max_len);
+ nl_msg_put_u64(ctx->odp_actions, ODP_ACTION_ATTR_CONTROLLER, max_len);
break;
case OFPP_LOCAL:
add_output_action(ctx, ODPP_LOCAL);
add_pop_action(struct action_xlate_ctx *ctx)
{
if (ctx->odp_actions->size != ctx->last_pop_priority) {
- nl_msg_put_flag(ctx->odp_actions, ODPAT_POP_PRIORITY);
+ nl_msg_put_flag(ctx->odp_actions, ODP_ACTION_ATTR_POP_PRIORITY);
ctx->last_pop_priority = ctx->odp_actions->size;
}
}
/* Add ODP actions. */
remove_pop_action(ctx);
- nl_msg_put_u32(ctx->odp_actions, ODPAT_SET_PRIORITY, priority);
+ nl_msg_put_u32(ctx->odp_actions, ODP_ACTION_ATTR_SET_PRIORITY, priority);
add_output_action(ctx, odp_port);
add_pop_action(ctx);
}
remove_pop_action(ctx);
- nl_msg_put_u32(ctx->odp_actions, ODPAT_SET_PRIORITY, priority);
+ nl_msg_put_u32(ctx->odp_actions, ODP_ACTION_ATTR_SET_PRIORITY, priority);
}
static void
{
ovs_be16 tci = ctx->flow.vlan_tci;
if (!(tci & htons(VLAN_CFI))) {
- nl_msg_put_flag(ctx->odp_actions, ODPAT_STRIP_VLAN);
+ nl_msg_put_flag(ctx->odp_actions, ODP_ACTION_ATTR_STRIP_VLAN);
} else {
- nl_msg_put_be16(ctx->odp_actions, ODPAT_SET_DL_TCI,
+ nl_msg_put_be16(ctx->odp_actions, ODP_ACTION_ATTR_SET_DL_TCI,
tci & ~htons(VLAN_CFI));
}
}
xlate_set_dl_tci(ctx);
}
if (ctx->flow.tun_id != state->tun_id) {
- nl_msg_put_be64(ctx->odp_actions, ODPAT_SET_TUNNEL, ctx->flow.tun_id);
+ nl_msg_put_be64(ctx->odp_actions,
+ ODP_ACTION_ATTR_SET_TUNNEL, ctx->flow.tun_id);
}
}
case NXAST_SET_TUNNEL:
nast = (const struct nx_action_set_tunnel *) nah;
tun_id = htonll(ntohl(nast->tun_id));
- nl_msg_put_be64(ctx->odp_actions, ODPAT_SET_TUNNEL, tun_id);
+ nl_msg_put_be64(ctx->odp_actions, ODP_ACTION_ATTR_SET_TUNNEL, tun_id);
ctx->flow.tun_id = tun_id;
break;
case NXAST_DROP_SPOOFED_ARP:
if (ctx->flow.dl_type == htons(ETH_TYPE_ARP)) {
- nl_msg_put_flag(ctx->odp_actions, ODPAT_DROP_SPOOFED_ARP);
+ nl_msg_put_flag(ctx->odp_actions,
+ ODP_ACTION_ATTR_DROP_SPOOFED_ARP);
}
break;
case NXAST_SET_TUNNEL64:
tun_id = ((const struct nx_action_set_tunnel64 *) nah)->tun_id;
- nl_msg_put_be64(ctx->odp_actions, ODPAT_SET_TUNNEL, tun_id);
+ nl_msg_put_be64(ctx->odp_actions, ODP_ACTION_ATTR_SET_TUNNEL, tun_id);
ctx->flow.tun_id = tun_id;
break;
case OFPAT_SET_DL_SRC:
oada = ((struct ofp_action_dl_addr *) ia);
- nl_msg_put_unspec(ctx->odp_actions, ODPAT_SET_DL_SRC,
+ nl_msg_put_unspec(ctx->odp_actions, ODP_ACTION_ATTR_SET_DL_SRC,
oada->dl_addr, ETH_ADDR_LEN);
memcpy(ctx->flow.dl_src, oada->dl_addr, ETH_ADDR_LEN);
break;
case OFPAT_SET_DL_DST:
oada = ((struct ofp_action_dl_addr *) ia);
- nl_msg_put_unspec(ctx->odp_actions, ODPAT_SET_DL_DST,
+ nl_msg_put_unspec(ctx->odp_actions, ODP_ACTION_ATTR_SET_DL_DST,
oada->dl_addr, ETH_ADDR_LEN);
memcpy(ctx->flow.dl_dst, oada->dl_addr, ETH_ADDR_LEN);
break;
case OFPAT_SET_NW_SRC:
- nl_msg_put_be32(ctx->odp_actions, ODPAT_SET_NW_SRC,
+ nl_msg_put_be32(ctx->odp_actions, ODP_ACTION_ATTR_SET_NW_SRC,
ia->nw_addr.nw_addr);
ctx->flow.nw_src = ia->nw_addr.nw_addr;
break;
case OFPAT_SET_NW_DST:
- nl_msg_put_be32(ctx->odp_actions, ODPAT_SET_NW_DST,
+ nl_msg_put_be32(ctx->odp_actions, ODP_ACTION_ATTR_SET_NW_DST,
ia->nw_addr.nw_addr);
ctx->flow.nw_dst = ia->nw_addr.nw_addr;
break;
case OFPAT_SET_NW_TOS:
- nl_msg_put_u8(ctx->odp_actions, ODPAT_SET_NW_TOS,
+ nl_msg_put_u8(ctx->odp_actions, ODP_ACTION_ATTR_SET_NW_TOS,
ia->nw_tos.nw_tos);
ctx->flow.nw_tos = ia->nw_tos.nw_tos;
break;
case OFPAT_SET_TP_SRC:
- nl_msg_put_be16(ctx->odp_actions, ODPAT_SET_TP_SRC,
+ nl_msg_put_be16(ctx->odp_actions, ODP_ACTION_ATTR_SET_TP_SRC,
ia->tp_port.tp_port);
ctx->flow.tp_src = ia->tp_port.tp_port;
break;
case OFPAT_SET_TP_DST:
- nl_msg_put_be16(ctx->odp_actions, ODPAT_SET_TP_DST,
+ nl_msg_put_be16(ctx->odp_actions, ODP_ACTION_ATTR_SET_TP_DST,
ia->tp_port.tp_port);
ctx->flow.tp_dst = ia->tp_port.tp_port;
break;
struct ofpbuf odp_actions;
ofpbuf_init(&odp_actions, 32);
- nl_msg_put_u32(&odp_actions, ODPAT_OUTPUT, ODPP_LOCAL);
+ nl_msg_put_u32(&odp_actions, ODP_ACTION_ATTR_OUTPUT, ODPP_LOCAL);
dpif_execute(p->dpif, odp_actions.data, odp_actions.size,
upcall->packet);
ofpbuf_uninit(&odp_actions);
flood_packets(ofproto, flow->in_port, OFPPC_NO_FLOOD,
nf_output_iface, odp_actions);
} else if (out_port != flow->in_port) {
- nl_msg_put_u32(odp_actions, ODPAT_OUTPUT, out_port);
+ nl_msg_put_u32(odp_actions, ODP_ACTION_ATTR_OUTPUT, out_port);
*nf_output_iface = out_port;
} else {
/* Drop. */
const struct dst *dst = &set.dsts[i];
if (dst->vlan != cur_vlan) {
if (dst->vlan == OFP_VLAN_NONE) {
- nl_msg_put_flag(actions, ODPAT_STRIP_VLAN);
+ nl_msg_put_flag(actions, ODP_ACTION_ATTR_STRIP_VLAN);
} else {
ovs_be16 tci;
tci = htons(dst->vlan & VLAN_VID_MASK);
tci |= flow->vlan_tci & htons(VLAN_PCP_MASK);
- nl_msg_put_be16(actions, ODPAT_SET_DL_TCI, tci);
+ nl_msg_put_be16(actions, ODP_ACTION_ATTR_SET_DL_TCI, tci);
}
cur_vlan = dst->vlan;
}
- nl_msg_put_u32(actions, ODPAT_OUTPUT, dst->dp_ifidx);
+ nl_msg_put_u32(actions, ODP_ACTION_ATTR_OUTPUT, dst->dp_ifidx);
}
dst_set_free(&set);
}
return;
}
NL_ATTR_FOR_EACH_UNSAFE (a, left, actions, actions_len) {
- if (nl_attr_type(a) == ODPAT_OUTPUT) {
+ if (nl_attr_type(a) == ODP_ACTION_ATTR_OUTPUT) {
struct port *out_port = port_from_dp_ifidx(br, nl_attr_get_u32(a));
if (out_port && out_port->n_ifaces >= 2 &&
out_port->bond_mode == BM_SLB) {