From: Ben Pfaff Date: Mon, 24 Jan 2011 05:56:00 +0000 (-0800) Subject: datapath: s/ODPAT_/ODP_ACTION_ATTR_/ to fit new naming scheme. X-Git-Tag: v1.1.0~379 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=7aec165dbc4690c8c2c703d142e2f017bb851d31;p=sliver-openvswitch.git datapath: s/ODPAT_/ODP_ACTION_ATTR_/ to fit new naming scheme. Jesse suggested this naming scheme, so I'm adjusting existing names to fit it. Signed-off-by: Ben Pfaff Acked-by: Jesse Gross --- diff --git a/datapath/actions.c b/datapath/actions.c index 1cb5f2202..3223c65bd 100644 --- a/datapath/actions.c +++ b/datapath/actions.c @@ -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)) @@ -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); @@ -399,11 +399,11 @@ 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); @@ -411,57 +411,57 @@ static int do_execute_actions(struct datapath *dp, struct sk_buff *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; diff --git a/datapath/datapath.c b/datapath/datapath.c index dee1b0f88..10eb5b7b2 100644 --- a/datapath/datapath.c +++ b/datapath/datapath.c @@ -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; diff --git a/include/openvswitch/datapath-protocol.h b/include/openvswitch/datapath-protocol.h index 083800cc8..1fb0bf991 100644 --- a/include/openvswitch/datapath-protocol.h +++ b/include/openvswitch/datapath-protocol.h @@ -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. */ @@ -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. @@ -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 }; @@ -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. */ @@ -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 */ diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index 5f7220840..417ed6e67 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -701,43 +701,43 @@ dpif_netdev_validate_actions(const struct nlattr *actions, } 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; } @@ -1215,7 +1215,7 @@ dp_netdev_set_nw_addr(struct ofpbuf *packet, const struct flow *key, 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); @@ -1261,12 +1261,14 @@ dp_netdev_set_tp_port(struct ofpbuf *packet, const struct flow *key, 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 { @@ -1357,46 +1359,46 @@ dp_netdev_execute_actions(struct dp_netdev *dp, 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; } diff --git a/lib/dpif-provider.h b/lib/dpif-provider.h index 61bc872cf..91074d507 100644 --- a/lib/dpif-provider.h +++ b/lib/dpif-provider.h @@ -211,7 +211,8 @@ struct dpif_class { /* 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 @@ -264,9 +265,9 @@ struct dpif_class { * 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 @@ -318,7 +319,7 @@ struct dpif_class { 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); diff --git a/lib/dpif.c b/lib/dpif.c index 3a705b91a..a754613a0 100644 --- a/lib/dpif.c +++ b/lib/dpif.c @@ -741,7 +741,7 @@ dpif_flow_get(const struct dpif *dpif, /* 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 @@ -845,9 +845,9 @@ dpif_flow_dump_start(struct dpif_flow_dump *dump, const struct dpif *dpif) * 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 @@ -1087,9 +1087,9 @@ dpif_get_netflow_ids(const struct dpif *dpif, } /* 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) diff --git a/lib/dpif.h b/lib/dpif.h index f5b749346..8872a2ef7 100644 --- a/lib/dpif.h +++ b/lib/dpif.h @@ -151,7 +151,7 @@ int dpif_execute(struct dpif *, const struct nlattr *actions, 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 }; @@ -171,7 +171,7 @@ struct dpif_upcall { 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. */ diff --git a/lib/odp-util.c b/lib/odp-util.c index 41acd6c5d..c70ea3580 100644 --- a/lib/odp-util.c +++ b/lib/odp-util.c @@ -33,29 +33,29 @@ 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; } @@ -95,56 +95,56 @@ format_odp_action(struct ds *ds, const struct nlattr *a) } 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: diff --git a/ofproto/in-band.c b/ofproto/in-band.c index 6623aca0b..94d2cb573 100644 --- a/ofproto/in-band.c +++ b/ofproto/in-band.c @@ -1,5 +1,5 @@ /* - * 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. @@ -445,7 +445,7 @@ in_band_rule_check(struct in_band *in_band, const struct flow *flow, 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; } diff --git a/ofproto/ofproto-sflow.c b/ofproto/ofproto-sflow.c index b3206c12e..05794e1c1 100644 --- a/ofproto/ofproto-sflow.c +++ b/ofproto/ofproto-sflow.c @@ -1,5 +1,5 @@ /* - * 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"); @@ -536,13 +536,13 @@ ofproto_sflow_received(struct ofproto_sflow *os, 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); diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c index 76878fcb8..67ce714d0 100644 --- a/ofproto/ofproto.c +++ b/ofproto/ofproto.c @@ -138,7 +138,7 @@ struct action_xlate_ctx { 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 *, @@ -2088,7 +2088,7 @@ execute_odp_actions(struct ofproto *ofproto, const struct flow *flow, 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. */ @@ -2682,7 +2682,7 @@ add_output_action(struct action_xlate_ctx *ctx, uint16_t port) */ } - 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; } @@ -2733,7 +2733,7 @@ flood_packets(struct ofproto *ofproto, uint16_t odp_in_port, uint32_t mask, 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; @@ -2773,7 +2773,7 @@ xlate_output_action__(struct action_xlate_ctx *ctx, &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); @@ -2820,7 +2820,7 @@ static void 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; } } @@ -2851,7 +2851,7 @@ xlate_enqueue_action(struct action_xlate_ctx *ctx, /* 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); @@ -2879,7 +2879,7 @@ xlate_set_queue_action(struct action_xlate_ctx *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 @@ -2887,9 +2887,9 @@ xlate_set_dl_tci(struct action_xlate_ctx *ctx) { 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)); } } @@ -2915,7 +2915,8 @@ update_reg_state(struct action_xlate_ctx *ctx, 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); } } @@ -2941,13 +2942,14 @@ xlate_nicira_action(struct action_xlate_ctx *ctx, 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; @@ -2980,7 +2982,7 @@ xlate_nicira_action(struct action_xlate_ctx *ctx, 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; @@ -3044,44 +3046,44 @@ do_xlate_actions(const union ofp_action *in, size_t n_in, 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; @@ -4374,7 +4376,7 @@ handle_miss_upcall(struct ofproto *p, struct dpif_upcall *upcall) 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); @@ -5112,7 +5114,7 @@ default_normal_ofhook_cb(const struct flow *flow, const struct ofpbuf *packet, 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. */ diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c index 463a8b511..fab619470 100644 --- a/vswitchd/bridge.c +++ b/vswitchd/bridge.c @@ -2631,16 +2631,16 @@ compose_actions(struct bridge *br, const struct flow *flow, uint16_t vlan, 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); } @@ -2934,7 +2934,7 @@ bridge_account_flow_ofhook_cb(const struct flow *flow, tag_type tags, 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) {