[ovs-dev] [netlink 10/16] datapath: Rename "struct odp_flow_key" as "struct vsfkey_openflow10".
Ben Pfaff
blp at nicira.com
Fri Sep 10 22:55:10 UTC 2010
The upcoming conversion to Netlink will generalize support for flow keys,
so the naming should not be generic any longer. This commit just renames
odp_flow_key and its members to match the new convention.
Signed-off-by: Ben Pfaff <blp at nicira.com>
---
datapath/actions.c | 24 +++++-----
datapath/actions.h | 4 +-
datapath/datapath.c | 8 ++--
datapath/flow.c | 82 +++++++++++++++---------------
datapath/flow.h | 6 +-
datapath/odp-compat.h | 2 +-
include/openvswitch/datapath-protocol.h | 51 ++++++-------------
lib/dpif-netdev.c | 51 ++++++++++---------
lib/dpif.c | 4 +-
lib/flow.c | 8 ++--
lib/odp-util.c | 76 +++++++++++++++--------------
lib/odp-util.h | 10 ++--
lib/packets.h | 6 ++
ofproto/ofproto.c | 13 +++--
14 files changed, 169 insertions(+), 176 deletions(-)
diff --git a/datapath/actions.c b/datapath/actions.c
index 5ec7061..fca6737 100644
--- a/datapath/actions.c
+++ b/datapath/actions.c
@@ -71,7 +71,7 @@ static struct sk_buff *vlan_pull_tag(struct sk_buff *skb)
}
static struct sk_buff *modify_vlan_tci(struct datapath *dp, struct sk_buff *skb,
- const struct odp_flow_key *key,
+ const struct vsfkey_openflow10 *key,
const union odp_action *a, int n_actions)
{
__be16 mask = a->dl_tci.mask;
@@ -233,19 +233,19 @@ static void update_csum(__sum16 *sum, struct sk_buff *skb,
csum_unfold(*sum)));
}
-static bool is_ip(struct sk_buff *skb, const struct odp_flow_key *key)
+static bool is_ip(struct sk_buff *skb, const struct vsfkey_openflow10 *key)
{
- return (key->dl_type == htons(ETH_P_IP) &&
+ return (key->vsof10_dl_type == htons(ETH_P_IP) &&
skb->transport_header > skb->network_header);
}
-static __sum16 *get_l4_checksum(struct sk_buff *skb, const struct odp_flow_key *key)
+static __sum16 *get_l4_checksum(struct sk_buff *skb, const struct vsfkey_openflow10 *key)
{
int transport_len = skb->len - skb_transport_offset(skb);
- if (key->nw_proto == IPPROTO_TCP) {
+ if (key->vsof10_nw_proto == IPPROTO_TCP) {
if (likely(transport_len >= sizeof(struct tcphdr)))
return &tcp_hdr(skb)->check;
- } else if (key->nw_proto == IPPROTO_UDP) {
+ } else if (key->vsof10_nw_proto == IPPROTO_UDP) {
if (likely(transport_len >= sizeof(struct udphdr)))
return &udp_hdr(skb)->check;
}
@@ -253,7 +253,7 @@ static __sum16 *get_l4_checksum(struct sk_buff *skb, const struct odp_flow_key *
}
static struct sk_buff *set_nw_addr(struct sk_buff *skb,
- const struct odp_flow_key *key,
+ const struct vsfkey_openflow10 *key,
const struct odp_action_nw_addr *a)
{
struct iphdr *nh;
@@ -281,7 +281,7 @@ static struct sk_buff *set_nw_addr(struct sk_buff *skb,
}
static struct sk_buff *set_nw_tos(struct sk_buff *skb,
- const struct odp_flow_key *key,
+ const struct vsfkey_openflow10 *key,
const struct odp_action_nw_tos *a)
{
if (unlikely(!is_ip(skb, key)))
@@ -304,7 +304,7 @@ static struct sk_buff *set_nw_tos(struct sk_buff *skb,
}
static struct sk_buff *set_tp_port(struct sk_buff *skb,
- const struct odp_flow_key *key,
+ const struct vsfkey_openflow10 *key,
const struct odp_action_tp_port *a)
{
struct udphdr *th;
@@ -349,11 +349,11 @@ static struct sk_buff *set_tp_port(struct sk_buff *skb,
* or truncated header fields or one whose inner and outer Ethernet address
* differ.
*/
-static bool is_spoofed_arp(struct sk_buff *skb, const struct odp_flow_key *key)
+static bool is_spoofed_arp(struct sk_buff *skb, const struct vsfkey_openflow10 *key)
{
struct arp_eth_header *arp;
- if (key->dl_type != htons(ETH_P_ARP))
+ if (key->vsof10_dl_type != htons(ETH_P_ARP))
return false;
if (skb_network_offset(skb) + sizeof(struct arp_eth_header) > skb->len)
@@ -417,7 +417,7 @@ static void sflow_sample(struct datapath *dp, struct sk_buff *skb,
/* Execute a list of actions against 'skb'. */
int execute_actions(struct datapath *dp, struct sk_buff *skb,
- const struct odp_flow_key *key,
+ const struct vsfkey_openflow10 *key,
const union odp_action *a, int n_actions)
{
/* Every output action needs a separate clone of 'skb', but the common
diff --git a/datapath/actions.h b/datapath/actions.h
index f2962a7..ef9a3e5 100644
--- a/datapath/actions.h
+++ b/datapath/actions.h
@@ -14,11 +14,11 @@
struct datapath;
struct sk_buff;
-struct odp_flow_key;
union odp_action;
+struct vsfkey_openflow10;
int execute_actions(struct datapath *dp, struct sk_buff *skb,
- const struct odp_flow_key *key,
+ const struct vsfkey_openflow10 *key,
const union odp_action *, int n_actions);
static inline void set_skb_csum_bits(const struct sk_buff *old_skb,
diff --git a/datapath/datapath.c b/datapath/datapath.c
index f0c6833..e53dacf 100644
--- a/datapath/datapath.c
+++ b/datapath/datapath.c
@@ -500,7 +500,7 @@ void dp_process_received_packet(struct vport *p, struct sk_buff *skb)
struct datapath *dp = p->dp;
struct dp_stats_percpu *stats;
int stats_counter_off;
- struct odp_flow_key key;
+ struct vsfkey_openflow10 key;
struct tbl_node *flow_node;
struct sw_flow *flow;
struct sw_flow_actions *acts;
@@ -1145,7 +1145,7 @@ static int answer_query(struct sw_flow *flow, u32 query_flags,
&ufp->stats, actions, &ufp->n_actions);
}
-static struct sw_flow *do_del_flow(struct datapath *dp, struct odp_flow_key *key)
+static struct sw_flow *do_del_flow(struct datapath *dp, struct vsfkey_openflow10 *key)
{
struct tbl *table = rcu_dereference(dp->table);
struct tbl_node *flow_node;
@@ -1277,7 +1277,7 @@ static int do_flowvec_ioctl(struct datapath *dp, unsigned long argp,
static int do_execute(struct datapath *dp, const struct odp_execute *execute)
{
- struct odp_flow_key key;
+ struct vsfkey_openflow10 key;
struct sk_buff *skb;
struct sw_flow_actions *actions;
struct ethhdr *eth;
@@ -1711,7 +1711,7 @@ static int compat_get_flow(struct odp_flow *flow, const struct compat_odp_flow _
if (!access_ok(VERIFY_READ, compat, sizeof(struct compat_odp_flow)) ||
__copy_from_user(&flow->stats, &compat->stats, sizeof(struct odp_flow_stats)) ||
- __copy_from_user(&flow->key, &compat->key, sizeof(struct odp_flow_key)) ||
+ __copy_from_user(&flow->key, &compat->key, sizeof(struct vsfkey_openflow10)) ||
__get_user(actions, &compat->actions) ||
__get_user(flow->n_actions, &compat->n_actions) ||
__get_user(flow->flags, &compat->flags))
diff --git a/datapath/flow.c b/datapath/flow.c
index 06a2ce3..19da77b 100644
--- a/datapath/flow.c
+++ b/datapath/flow.c
@@ -90,8 +90,8 @@ void flow_used(struct sw_flow *flow, struct sk_buff *skb)
{
u8 tcp_flags = 0;
- if (flow->key.dl_type == htons(ETH_P_IP) &&
- flow->key.nw_proto == IPPROTO_TCP) {
+ if (flow->key.vsof10_dl_type == htons(ETH_P_IP) &&
+ flow->key.vsof10_nw_proto == IPPROTO_TCP) {
u8 *tcp = (u8 *)tcp_hdr(skb);
tcp_flags = *(tcp + TCP_FLAGS_OFFSET) & TCP_FLAG_MASK;
}
@@ -165,7 +165,7 @@ void flow_deferred_free_acts(struct sw_flow_actions *sf_acts)
call_rcu(&sf_acts->rcu, rcu_free_acts_callback);
}
-static void parse_vlan(struct sk_buff *skb, struct odp_flow_key *key)
+static void parse_vlan(struct sk_buff *skb, struct vsfkey_openflow10 *key)
{
struct qtag_prefix {
__be16 eth_type; /* ETH_P_8021Q */
@@ -177,7 +177,7 @@ static void parse_vlan(struct sk_buff *skb, struct odp_flow_key *key)
return;
qp = (struct qtag_prefix *) skb->data;
- key->dl_tci = qp->tci | htons(ODP_TCI_PRESENT);
+ key->vsof10_dl_tci = qp->tci | htons(VSOF10_TCI_PRESENT);
__skb_pull(skb, sizeof(struct qtag_prefix));
}
@@ -196,17 +196,17 @@ static __be16 parse_ethertype(struct sk_buff *skb)
proto = *(__be16 *) skb->data;
__skb_pull(skb, sizeof(__be16));
- if (ntohs(proto) >= ODP_DL_TYPE_ETH2_CUTOFF)
+ if (ntohs(proto) >= 1536)
return proto;
if (unlikely(skb->len < sizeof(struct llc_snap_hdr)))
- return htons(ODP_DL_TYPE_NOT_ETH_TYPE);
+ return htons(VSOF10_NOT_ETH_TYPE);
llc = (struct llc_snap_hdr *) skb->data;
if (llc->dsap != LLC_SAP_SNAP ||
llc->ssap != LLC_SAP_SNAP ||
(llc->oui[0] | llc->oui[1] | llc->oui[2]) != 0)
- return htons(ODP_DL_TYPE_NOT_ETH_TYPE);
+ return htons(VSOF10_NOT_ETH_TYPE);
__skb_pull(skb, sizeof(struct llc_snap_hdr));
return llc->ethertype;
@@ -230,21 +230,21 @@ static __be16 parse_ethertype(struct sk_buff *skb)
* - skb->network_header: just past the Ethernet header, or just past the
* VLAN header, to the first byte of the Ethernet payload.
*
- * - skb->transport_header: If key->dl_type is ETH_P_IP on output, then just
- * past the IPv4 header, if one is present and of a correct length,
- * otherwise the same as skb->network_header. For other key->dl_type
- * values it is left untouched.
+ * - skb->transport_header: If key->vsof10_dl_type is ETH_P_IP on output,
+ * then just past the IPv4 header, if one is present and of a correct
+ * length, otherwise the same as skb->network_header. For other
+ * Ethertypes it is left untouched.
*
* Sets OVS_CB(skb)->is_frag to %true if @skb is an IPv4 fragment, otherwise to
* %false.
*/
-int flow_extract(struct sk_buff *skb, u16 in_port, struct odp_flow_key *key)
+int flow_extract(struct sk_buff *skb, u16 in_port, struct vsfkey_openflow10 *key)
{
struct ethhdr *eth;
memset(key, 0, sizeof *key);
- key->tun_id = OVS_CB(skb)->tun_id;
- key->in_port = in_port;
+ key->vsof10_tun_id = OVS_CB(skb)->tun_id;
+ key->vsof10_in_port = in_port;
OVS_CB(skb)->is_frag = false;
/*
@@ -271,19 +271,19 @@ int flow_extract(struct sk_buff *skb, u16 in_port, struct odp_flow_key *key)
/* Link layer. */
eth = eth_hdr(skb);
- memcpy(key->dl_src, eth->h_source, ETH_ALEN);
- memcpy(key->dl_dst, eth->h_dest, ETH_ALEN);
+ memcpy(key->vsof10_dl_src, eth->h_source, ETH_ALEN);
+ memcpy(key->vsof10_dl_dst, eth->h_dest, ETH_ALEN);
/* dl_type, dl_vlan, dl_vlan_pcp. */
__skb_pull(skb, 2 * ETH_ALEN);
if (eth->h_proto == htons(ETH_P_8021Q))
parse_vlan(skb, key);
- key->dl_type = parse_ethertype(skb);
+ key->vsof10_dl_type = parse_ethertype(skb);
skb_reset_network_header(skb);
__skb_push(skb, skb->data - (unsigned char *)eth);
/* Network layer. */
- if (key->dl_type == htons(ETH_P_IP)) {
+ if (key->vsof10_dl_type == htons(ETH_P_IP)) {
struct iphdr *nh;
int error;
@@ -297,39 +297,39 @@ int flow_extract(struct sk_buff *skb, u16 in_port, struct odp_flow_key *key)
}
nh = ip_hdr(skb);
- key->nw_src = nh->saddr;
- key->nw_dst = nh->daddr;
- key->nw_tos = nh->tos & ~INET_ECN_MASK;
- key->nw_proto = nh->protocol;
+ key->vsof10_nw_src = nh->saddr;
+ key->vsof10_nw_dst = nh->daddr;
+ key->vsof10_nw_tos = nh->tos & ~INET_ECN_MASK;
+ key->vsof10_nw_proto = nh->protocol;
/* Transport layer. */
if (!(nh->frag_off & htons(IP_MF | IP_OFFSET))) {
- if (key->nw_proto == IPPROTO_TCP) {
+ if (key->vsof10_nw_proto == IPPROTO_TCP) {
if (tcphdr_ok(skb)) {
struct tcphdr *tcp = tcp_hdr(skb);
- key->tp_src = tcp->source;
- key->tp_dst = tcp->dest;
+ key->vsof10_tp_src = tcp->source;
+ key->vsof10_tp_dst = tcp->dest;
}
- } else if (key->nw_proto == IPPROTO_UDP) {
+ } else if (key->vsof10_nw_proto == IPPROTO_UDP) {
if (udphdr_ok(skb)) {
struct udphdr *udp = udp_hdr(skb);
- key->tp_src = udp->source;
- key->tp_dst = udp->dest;
+ key->vsof10_tp_src = udp->source;
+ key->vsof10_tp_dst = udp->dest;
}
- } else if (key->nw_proto == IPPROTO_ICMP) {
+ } else if (key->vsof10_nw_proto == IPPROTO_ICMP) {
if (icmphdr_ok(skb)) {
struct icmphdr *icmp = icmp_hdr(skb);
/* The ICMP type and code fields use the 16-bit
* transport port fields, so we need to store them
* in 16-bit network byte order. */
- key->tp_src = htons(icmp->type);
- key->tp_dst = htons(icmp->code);
+ key->vsof10_tp_src = htons(icmp->type);
+ key->vsof10_tp_dst = htons(icmp->code);
}
}
} else {
OVS_CB(skb)->is_frag = true;
}
- } else if (key->dl_type == htons(ETH_P_ARP) && arphdr_ok(skb)) {
+ } else if (key->vsof10_dl_type == htons(ETH_P_ARP) && arphdr_ok(skb)) {
struct arp_eth_header *arp;
arp = (struct arp_eth_header *)skb_network_header(skb);
@@ -341,30 +341,30 @@ int flow_extract(struct sk_buff *skb, u16 in_port, struct odp_flow_key *key)
/* We only match on the lower 8 bits of the opcode. */
if (ntohs(arp->ar_op) <= 0xff) {
- key->nw_proto = ntohs(arp->ar_op);
+ key->vsof10_nw_proto = ntohs(arp->ar_op);
}
- if (key->nw_proto == ARPOP_REQUEST
- || key->nw_proto == ARPOP_REPLY) {
- memcpy(&key->nw_src, arp->ar_sip, sizeof(key->nw_src));
- memcpy(&key->nw_dst, arp->ar_tip, sizeof(key->nw_dst));
+ if (key->vsof10_nw_proto == ARPOP_REQUEST
+ || key->vsof10_nw_proto == ARPOP_REPLY) {
+ memcpy(&key->vsof10_nw_src, arp->ar_sip, 4);
+ memcpy(&key->vsof10_nw_dst, arp->ar_tip, 4);
}
}
}
return 0;
}
-u32 flow_hash(const struct odp_flow_key *key)
+u32 flow_hash(const struct vsfkey_openflow10 *key)
{
return jhash2((u32*)key, sizeof *key / sizeof(u32), hash_seed);
}
int flow_cmp(const struct tbl_node *node, void *key2_)
{
- const struct odp_flow_key *key1 = &flow_cast(node)->key;
- const struct odp_flow_key *key2 = key2_;
+ const struct vsfkey_openflow10 *key1 = &flow_cast(node)->key;
+ const struct vsfkey_openflow10 *key2 = key2_;
- return !memcmp(key1, key2, sizeof(struct odp_flow_key));
+ return !memcmp(key1, key2, sizeof(struct vsfkey_openflow10));
}
/* Initializes the flow module.
diff --git a/datapath/flow.h b/datapath/flow.h
index a4f116e..1d0b79c 100644
--- a/datapath/flow.h
+++ b/datapath/flow.h
@@ -32,7 +32,7 @@ struct sw_flow {
struct rcu_head rcu;
struct tbl_node tbl_node;
- struct odp_flow_key key;
+ struct vsfkey_openflow10 key;
struct sw_flow_actions *sf_acts;
spinlock_t lock; /* Lock for values below. */
@@ -62,10 +62,10 @@ extern struct kmem_cache *flow_cache;
struct sw_flow_actions *flow_actions_alloc(size_t n_actions);
void flow_deferred_free(struct sw_flow *);
void flow_deferred_free_acts(struct sw_flow_actions *);
-int flow_extract(struct sk_buff *, u16 in_port, struct odp_flow_key *);
+int flow_extract(struct sk_buff *, u16 in_port, struct vsfkey_openflow10 *);
void flow_used(struct sw_flow *, struct sk_buff *);
-u32 flow_hash(const struct odp_flow_key *key);
+u32 flow_hash(const struct vsfkey_openflow10 *);
int flow_cmp(const struct tbl_node *, void *target);
void flow_free_tbl(struct tbl_node *);
diff --git a/datapath/odp-compat.h b/datapath/odp-compat.h
index d30b05f..6e83f44 100644
--- a/datapath/odp-compat.h
+++ b/datapath/odp-compat.h
@@ -30,7 +30,7 @@ struct compat_odp_portvec {
struct compat_odp_flow {
struct odp_flow_stats stats;
- struct odp_flow_key key;
+ struct vsfkey_openflow10 key;
compat_uptr_t actions;
u32 n_actions;
u32 flags;
diff --git a/include/openvswitch/datapath-protocol.h b/include/openvswitch/datapath-protocol.h
index 145a119..faf0444 100644
--- a/include/openvswitch/datapath-protocol.h
+++ b/include/openvswitch/datapath-protocol.h
@@ -204,29 +204,23 @@ struct odp_flow_stats {
uint16_t error; /* Used by ODP_FLOW_GET. */
};
-/*
- * The datapath protocol adopts the Linux convention for TCI fields: if an
- * 802.1Q header is present then its TCI value is used verbatim except that the
- * CFI bit (0x1000) is always set to 1, and all-bits-zero indicates no 802.1Q
- * header.
- */
-#define ODP_TCI_PRESENT 0x1000 /* CFI bit */
-
-struct odp_flow_key {
- ovs_be32 tun_id; /* Encapsulating tunnel ID. */
- ovs_be32 nw_src; /* IP source address. */
- ovs_be32 nw_dst; /* IP destination address. */
- uint16_t in_port; /* Input switch port. */
- ovs_be16 dl_tci; /* All zeros if 802.1Q header absent,
- * ODP_TCI_PRESENT set if present. */
- ovs_be16 dl_type; /* Ethernet frame type. */
- ovs_be16 tp_src; /* TCP/UDP source port. */
- ovs_be16 tp_dst; /* TCP/UDP destination port. */
- uint8_t dl_src[6]; /* Ethernet source address. */
- uint8_t dl_dst[6]; /* Ethernet destination address. */
- uint8_t nw_proto; /* IP protocol or lower 8 bits of
+struct vsfkey_openflow10 {
+ ovs_be32 vsof10_tun_id; /* Encapsulating tunnel ID. */
+ ovs_be32 vsof10_nw_src; /* IP source address. */
+ ovs_be32 vsof10_nw_dst; /* IP destination address. */
+ uint16_t vsof10_in_port; /* Input switch port. */
+ ovs_be16 vsof10_dl_tci; /* All zeros if 802.1Q header absent,
+ * ODP_TCI_PRESENT set if present. */
+#define VSOF10_TCI_PRESENT 0x1000 /* Set in dl_tci if 802.1Q header present. */
+ ovs_be16 vsof10_dl_type; /* Ethernet frame type. */
+#define VSOF10_NOT_ETH_TYPE 0x5ff /* No Ethernet frame type present. */
+ ovs_be16 vsof10_tp_src; /* TCP/UDP source port. */
+ ovs_be16 vsof10_tp_dst; /* TCP/UDP destination port. */
+ uint8_t vsof10_dl_src[6]; /* Ethernet source address. */
+ uint8_t vsof10_dl_dst[6]; /* Ethernet destination address. */
+ uint8_t vsof10_nw_proto; /* IP protocol or lower 8 bits of
ARP opcode. */
- uint8_t nw_tos; /* IP ToS (DSCP field, 6 bits). */
+ uint8_t vsof10_nw_tos; /* IP ToS (DSCP field, 6 bits). */
};
/* Flags for ODP_FLOW. */
@@ -234,7 +228,7 @@ struct odp_flow_key {
struct odp_flow {
struct odp_flow_stats stats;
- struct odp_flow_key key;
+ struct vsfkey_openflow10 key;
union odp_action *actions;
uint32_t n_actions;
uint32_t flags;
@@ -389,15 +383,4 @@ struct odp_vport_mtu {
uint16_t mtu;
};
-/* Values below this cutoff are 802.3 packets and the two bytes
- * following MAC addresses are used as a frame length. Otherwise, the
- * two bytes are used as the Ethernet type.
- */
-#define ODP_DL_TYPE_ETH2_CUTOFF 0x0600
-
-/* Value of dl_type to indicate that the frame does not include an
- * Ethernet type.
- */
-#define ODP_DL_TYPE_NOT_ETH_TYPE 0x05ff
-
#endif /* openvswitch/datapath-protocol.h */
diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index 5f842e1..e630e9a 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -95,7 +95,7 @@ struct dp_netdev_port {
/* A flow in dp_netdev's 'flow_table'. */
struct dp_netdev_flow {
struct hmap_node node; /* Element in dp_netdev's 'flow_table'. */
- struct odp_flow_key key;
+ struct vsfkey_openflow10 key;
/* Statistics. */
struct timespec used; /* Last used time. */
@@ -137,7 +137,7 @@ static int do_del_port(struct dp_netdev *, uint16_t port_no);
static int dp_netdev_output_control(struct dp_netdev *, const struct ofpbuf *,
int queue_no, int port_no, uint32_t arg);
static int dp_netdev_execute_actions(struct dp_netdev *,
- struct ofpbuf *, struct odp_flow_key *,
+ struct ofpbuf *, struct vsfkey_openflow10 *,
const union odp_action *, int n);
static struct dpif_netdev *
@@ -605,13 +605,13 @@ dpif_netdev_port_poll_wait(const struct dpif *dpif_)
static struct dp_netdev_flow *
dp_netdev_lookup_flow(const struct dp_netdev *dp,
- const struct odp_flow_key *key)
+ const struct vsfkey_openflow10 *key)
{
struct dp_netdev_flow *flow;
HMAP_FOR_EACH_WITH_HASH (flow, struct dp_netdev_flow, node,
- odp_flow_key_hash(key, 0), &dp->flow_table) {
- if (odp_flow_key_equal(&flow->key, key)) {
+ vsfkey_openflow10_hash(key, 0), &dp->flow_table) {
+ if (vsfkey_openflow10_equal(&flow->key, key)) {
return flow;
}
}
@@ -756,7 +756,7 @@ add_flow(struct dpif *dpif, struct odp_flow *odp_flow)
}
hmap_insert(&dp->flow_table, &flow->node,
- odp_flow_key_hash(&flow->key, 0));
+ vsfkey_openflow10_hash(&flow->key, 0));
return 0;
}
@@ -842,7 +842,7 @@ dpif_netdev_execute(struct dpif *dpif,
struct dp_netdev *dp = get_dp_netdev(dpif);
struct ofpbuf copy;
bool mutates;
- struct odp_flow_key key;
+ struct vsfkey_openflow10 key;
struct flow flow;
int error;
@@ -869,7 +869,7 @@ dpif_netdev_execute(struct dpif *dpif,
copy = *packet;
}
flow_extract(©, 0, -1, &flow);
- odp_flow_key_from_flow(&key, &flow);
+ vsfkey_openflow10_from_flow(&key, &flow);
error = dp_netdev_execute_actions(dp, ©, &key, actions, n_actions);
if (mutates) {
ofpbuf_uninit(©);
@@ -940,13 +940,14 @@ dpif_netdev_recv_wait(struct dpif *dpif)
static void
dp_netdev_flow_used(struct dp_netdev_flow *flow,
- const struct odp_flow_key *key,
+ const struct vsfkey_openflow10 *key,
const struct ofpbuf *packet)
{
time_timespec(&flow->used);
flow->packet_count++;
flow->byte_count += packet->size;
- if (key->dl_type == htons(ETH_TYPE_IP) && key->nw_proto == IPPROTO_TCP) {
+ if (key->vsof10_dl_type == htons(ETH_TYPE_IP)
+ && key->vsof10_nw_proto == IPPROTO_TCP) {
struct tcp_header *th = packet->l4;
flow->tcp_ctl |= th->tcp_ctl;
}
@@ -957,7 +958,7 @@ dp_netdev_port_input(struct dp_netdev *dp, struct dp_netdev_port *port,
struct ofpbuf *packet)
{
struct dp_netdev_flow *flow;
- struct odp_flow_key key;
+ struct vsfkey_openflow10 key;
struct flow f;
if (packet->size < ETH_HEADER_LEN) {
@@ -967,7 +968,7 @@ dp_netdev_port_input(struct dp_netdev *dp, struct dp_netdev_port *port,
dp->n_frags++;
return;
}
- odp_flow_key_from_flow(&key, &f);
+ vsfkey_openflow10_from_flow(&key, &f);
flow = dp_netdev_lookup_flow(dp, &key);
if (flow) {
@@ -1095,13 +1096,13 @@ dp_netdev_set_dl_dst(struct ofpbuf *packet, const uint8_t dl_addr[ETH_ADDR_LEN])
}
static bool
-is_ip(const struct ofpbuf *packet, const struct odp_flow_key *key)
+is_ip(const struct ofpbuf *packet, const struct vsfkey_openflow10 *key)
{
- return key->dl_type == htons(ETH_TYPE_IP) && packet->l4;
+ return key->vsof10_dl_type == htons(ETH_TYPE_IP) && packet->l4;
}
static void
-dp_netdev_set_nw_addr(struct ofpbuf *packet, struct odp_flow_key *key,
+dp_netdev_set_nw_addr(struct ofpbuf *packet, struct vsfkey_openflow10 *key,
const struct odp_action_nw_addr *a)
{
if (is_ip(packet, key)) {
@@ -1109,10 +1110,10 @@ dp_netdev_set_nw_addr(struct ofpbuf *packet, struct odp_flow_key *key,
uint32_t *field;
field = a->type == ODPAT_SET_NW_SRC ? &nh->ip_src : &nh->ip_dst;
- if (key->nw_proto == IP_TYPE_TCP && packet->l7) {
+ if (key->vsof10_nw_proto == IP_TYPE_TCP && packet->l7) {
struct tcp_header *th = packet->l4;
th->tcp_csum = recalc_csum32(th->tcp_csum, *field, a->nw_addr);
- } else if (key->nw_proto == IP_TYPE_UDP && packet->l7) {
+ } else if (key->vsof10_nw_proto == IP_TYPE_UDP && packet->l7) {
struct udp_header *uh = packet->l4;
if (uh->udp_csum) {
uh->udp_csum = recalc_csum32(uh->udp_csum, *field, a->nw_addr);
@@ -1127,7 +1128,7 @@ dp_netdev_set_nw_addr(struct ofpbuf *packet, struct odp_flow_key *key,
}
static void
-dp_netdev_set_nw_tos(struct ofpbuf *packet, struct odp_flow_key *key,
+dp_netdev_set_nw_tos(struct ofpbuf *packet, struct vsfkey_openflow10 *key,
const struct odp_action_nw_tos *a)
{
if (is_ip(packet, key)) {
@@ -1144,17 +1145,17 @@ dp_netdev_set_nw_tos(struct ofpbuf *packet, struct odp_flow_key *key,
}
static void
-dp_netdev_set_tp_port(struct ofpbuf *packet, struct odp_flow_key *key,
+dp_netdev_set_tp_port(struct ofpbuf *packet, struct vsfkey_openflow10 *key,
const struct odp_action_tp_port *a)
{
if (is_ip(packet, key)) {
uint16_t *field;
- if (key->nw_proto == IPPROTO_TCP && packet->l7) {
+ if (key->vsof10_nw_proto == IPPROTO_TCP && packet->l7) {
struct tcp_header *th = packet->l4;
field = a->type == ODPAT_SET_TP_SRC ? &th->tcp_src : &th->tcp_dst;
th->tcp_csum = recalc_csum16(th->tcp_csum, *field, a->tp_port);
*field = a->tp_port;
- } else if (key->nw_proto == IPPROTO_UDP && packet->l7) {
+ } else if (key->vsof10_nw_proto == IPPROTO_UDP && packet->l7) {
struct udp_header *uh = packet->l4;
field = a->type == ODPAT_SET_TP_SRC ? &uh->udp_src : &uh->udp_dst;
uh->udp_csum = recalc_csum16(uh->udp_csum, *field, a->tp_port);
@@ -1206,13 +1207,13 @@ dp_netdev_output_control(struct dp_netdev *dp, const struct ofpbuf *packet,
* screwy or truncated header fields or one whose inner and outer Ethernet
* address differ. */
static bool
-dp_netdev_is_spoofed_arp(struct ofpbuf *packet, const struct odp_flow_key *key)
+dp_netdev_is_spoofed_arp(struct ofpbuf *packet, const struct vsfkey_openflow10 *key)
{
struct arp_eth_header *arp;
struct eth_header *eth;
ptrdiff_t l3_size;
- if (key->dl_type != htons(ETH_TYPE_ARP)) {
+ if (key->vsof10_dl_type != htons(ETH_TYPE_ARP)) {
return false;
}
@@ -1232,7 +1233,7 @@ dp_netdev_is_spoofed_arp(struct ofpbuf *packet, const struct odp_flow_key *key)
static int
dp_netdev_execute_actions(struct dp_netdev *dp,
- struct ofpbuf *packet, struct odp_flow_key *key,
+ struct ofpbuf *packet, struct vsfkey_openflow10 *key,
const union odp_action *actions, int n_actions)
{
int i;
@@ -1246,7 +1247,7 @@ dp_netdev_execute_actions(struct dp_netdev *dp,
case ODPAT_CONTROLLER:
dp_netdev_output_control(dp, packet, _ODPL_ACTION_NR,
- key->in_port, a->controller.arg);
+ key->vsof10_in_port, a->controller.arg);
break;
case ODPAT_SET_DL_TCI:
diff --git a/lib/dpif.c b/lib/dpif.c
index 21b24c1..07dbbb3 100644
--- a/lib/dpif.c
+++ b/lib/dpif.c
@@ -1111,7 +1111,7 @@ should_log_flow_message(int error)
static void
log_flow_message(const struct dpif *dpif, int error, const char *operation,
- const struct odp_flow_key *flow,
+ const struct vsfkey_openflow10 *flow,
const struct odp_flow_stats *stats,
const union odp_action *actions, size_t n_actions)
{
@@ -1124,7 +1124,7 @@ log_flow_message(const struct dpif *dpif, int error, const char *operation,
if (error) {
ds_put_format(&ds, "(%s) ", strerror(error));
}
- format_odp_flow_key(&ds, flow);
+ format_vsfkey_openflow10(&ds, flow);
if (stats) {
ds_put_cstr(&ds, ", ");
format_odp_flow_stats(&ds, stats);
diff --git a/lib/flow.c b/lib/flow.c
index 78c45ad..5cbaeb6 100644
--- a/lib/flow.c
+++ b/lib/flow.c
@@ -99,12 +99,12 @@ parse_ethertype(struct ofpbuf *b)
uint16_t proto;
proto = *(uint16_t *) ofpbuf_pull(b, sizeof proto);
- if (ntohs(proto) >= ODP_DL_TYPE_ETH2_CUTOFF) {
+ if (ntohs(proto) >= ETH_TYPE_MIN) {
return proto;
}
if (b->size < sizeof *llc) {
- return htons(ODP_DL_TYPE_NOT_ETH_TYPE);
+ return htons(VSOF10_NOT_ETH_TYPE);
}
llc = b->data;
@@ -113,7 +113,7 @@ parse_ethertype(struct ofpbuf *b)
|| llc->llc.llc_cntl != LLC_CNTL_SNAP
|| memcmp(llc->snap.snap_org, SNAP_ORG_ETHERNET,
sizeof llc->snap.snap_org)) {
- return htons(ODP_DL_TYPE_NOT_ETH_TYPE);
+ return htons(VSOF10_NOT_ETH_TYPE);
}
ofpbuf_pull(b, sizeof *llc);
@@ -121,7 +121,7 @@ parse_ethertype(struct ofpbuf *b)
}
/* 'tun_id' is in network byte order, while 'in_port' is in host byte order.
- * These byte orders are the same as they are in struct odp_flow_key.
+ * These byte orders are the same as they are in struct vsfkey_openflow10.
*
* Initializes packet header pointers as follows:
*
diff --git a/lib/odp-util.c b/lib/odp-util.c
index 2d2307c..ac95388 100644
--- a/lib/odp-util.c
+++ b/lib/odp-util.c
@@ -40,20 +40,20 @@ odp_actions_add(struct odp_actions *actions, uint16_t type)
}
void
-format_odp_flow_key(struct ds *ds, const struct odp_flow_key *key)
+format_vsfkey_openflow10(struct ds *ds, const struct vsfkey_openflow10 *key)
{
- ds_put_format(ds, "in_port%04x", key->in_port);
- if (key->dl_tci) {
+ ds_put_format(ds, "in_port%04x", key->vsof10_in_port);
+ if (key->vsof10_dl_tci) {
ds_put_format(ds, ":vlan%"PRIu16":pcp%d",
- vlan_tci_to_vid(key->dl_tci),
- vlan_tci_to_pcp(key->dl_tci));
+ vlan_tci_to_vid(key->vsof10_dl_tci),
+ vlan_tci_to_pcp(key->vsof10_dl_tci));
}
ds_put_format(ds, " mac"ETH_ADDR_FMT"->"ETH_ADDR_FMT" type%04x "
"proto%"PRId8" tos%"PRIu8" ip"IP_FMT"->"IP_FMT" port%d->%d",
- ETH_ADDR_ARGS(key->dl_src), ETH_ADDR_ARGS(key->dl_dst),
- ntohs(key->dl_type), key->nw_proto, key->nw_tos,
- IP_ARGS(&key->nw_src), IP_ARGS(&key->nw_dst),
- ntohs(key->tp_src), ntohs(key->tp_dst));
+ ETH_ADDR_ARGS(key->vsof10_dl_src), ETH_ADDR_ARGS(key->vsof10_dl_dst),
+ ntohs(key->vsof10_dl_type), key->vsof10_nw_proto, key->vsof10_nw_tos,
+ IP_ARGS(&key->vsof10_nw_src), IP_ARGS(&key->vsof10_nw_dst),
+ ntohs(key->vsof10_tp_src), ntohs(key->vsof10_tp_dst));
}
void
@@ -146,7 +146,7 @@ format_odp_flow_stats(struct ds *ds, const struct odp_flow_stats *s)
void
format_odp_flow(struct ds *ds, const struct odp_flow *f)
{
- format_odp_flow_key(ds, &f->key);
+ format_vsfkey_openflow10(ds, &f->key);
ds_put_cstr(ds, ", ");
format_odp_flow_stats(ds, &f->stats);
ds_put_cstr(ds, ", actions:");
@@ -154,46 +154,48 @@ format_odp_flow(struct ds *ds, const struct odp_flow *f)
}
void
-odp_flow_key_from_flow(struct odp_flow_key *key, const struct flow *flow)
+vsfkey_openflow10_from_flow(struct vsfkey_openflow10 *key,
+ const struct flow *flow)
{
- key->nw_src = flow->nw_src;
- key->nw_dst = flow->nw_dst;
- key->in_port = flow->in_port;
+ key->vsof10_nw_src = flow->nw_src;
+ key->vsof10_nw_dst = flow->nw_dst;
+ key->vsof10_in_port = flow->in_port;
if (flow->dl_vlan == htons(OFP_VLAN_NONE)) {
- key->dl_tci = htons(0);
+ key->vsof10_dl_tci = htons(0);
} else {
uint16_t vid = flow->dl_vlan & htons(VLAN_VID_MASK);
uint16_t pcp = htons((flow->dl_vlan_pcp << VLAN_PCP_SHIFT)
& VLAN_PCP_MASK);
- key->dl_tci = vid | pcp | htons(ODP_TCI_PRESENT);
+ key->vsof10_dl_tci = vid | pcp | htons(VSOF10_TCI_PRESENT);
}
- key->dl_type = flow->dl_type;
- key->tp_src = flow->tp_src;
- key->tp_dst = flow->tp_dst;
- memcpy(key->dl_src, flow->dl_src, ETH_ADDR_LEN);
- memcpy(key->dl_dst, flow->dl_dst, ETH_ADDR_LEN);
- key->nw_proto = flow->nw_proto;
- key->nw_tos = flow->nw_tos;
+ key->vsof10_dl_type = flow->dl_type;
+ key->vsof10_tp_src = flow->tp_src;
+ key->vsof10_tp_dst = flow->tp_dst;
+ memcpy(key->vsof10_dl_src, flow->dl_src, ETH_ADDR_LEN);
+ memcpy(key->vsof10_dl_dst, flow->dl_dst, ETH_ADDR_LEN);
+ key->vsof10_nw_proto = flow->nw_proto;
+ key->vsof10_nw_tos = flow->nw_tos;
}
void
-odp_flow_key_to_flow(const struct odp_flow_key *key, struct flow *flow)
+vsfkey_openflow10_to_flow(const struct vsfkey_openflow10 *key,
+ struct flow *flow)
{
- flow->nw_src = key->nw_src;
- flow->nw_dst = key->nw_dst;
- flow->in_port = key->in_port;
- if (key->dl_tci) {
- flow->dl_vlan = htons(vlan_tci_to_vid(key->dl_tci));
- flow->dl_vlan_pcp = vlan_tci_to_pcp(key->dl_tci);
+ flow->nw_src = key->vsof10_nw_src;
+ flow->nw_dst = key->vsof10_nw_dst;
+ flow->in_port = key->vsof10_in_port;
+ if (key->vsof10_dl_tci) {
+ flow->dl_vlan = htons(vlan_tci_to_vid(key->vsof10_dl_tci));
+ flow->dl_vlan_pcp = vlan_tci_to_pcp(key->vsof10_dl_tci);
} else {
flow->dl_vlan = htons(OFP_VLAN_NONE);
flow->dl_vlan_pcp = 0;
}
- flow->dl_type = key->dl_type;
- flow->tp_src = key->tp_src;
- flow->tp_dst = key->tp_dst;
- memcpy(flow->dl_src, key->dl_src, ETH_ADDR_LEN);
- memcpy(flow->dl_dst, key->dl_dst, ETH_ADDR_LEN);
- flow->nw_proto = key->nw_proto;
- flow->nw_tos = key->nw_tos;
+ flow->dl_type = key->vsof10_dl_type;
+ flow->tp_src = key->vsof10_tp_src;
+ flow->tp_dst = key->vsof10_tp_dst;
+ memcpy(flow->dl_src, key->vsof10_dl_src, ETH_ADDR_LEN);
+ memcpy(flow->dl_dst, key->vsof10_dl_dst, ETH_ADDR_LEN);
+ flow->nw_proto = key->vsof10_nw_proto;
+ flow->nw_tos = key->vsof10_nw_tos;
}
diff --git a/lib/odp-util.h b/lib/odp-util.h
index 9cbf7dd..d14e6df 100644
--- a/lib/odp-util.h
+++ b/lib/odp-util.h
@@ -81,24 +81,24 @@ odp_port_to_ofp_port(uint16_t odp_port)
}
}
-void format_odp_flow_key(struct ds *, const struct odp_flow_key *);
+void format_vsfkey_openflow10(struct ds *, const struct vsfkey_openflow10 *);
void format_odp_action(struct ds *, const union odp_action *);
void format_odp_actions(struct ds *, const union odp_action *actions,
size_t n_actions);
void format_odp_flow_stats(struct ds *, const struct odp_flow_stats *);
void format_odp_flow(struct ds *, const struct odp_flow *);
-void odp_flow_key_from_flow(struct odp_flow_key *, const struct flow *);
-void odp_flow_key_to_flow(const struct odp_flow_key *, struct flow *);
+void vsfkey_openflow10_from_flow(struct vsfkey_openflow10 *, const struct flow *);
+void vsfkey_openflow10_to_flow(const struct vsfkey_openflow10 *, struct flow *);
static inline bool
-odp_flow_key_equal(const struct odp_flow_key *a, const struct odp_flow_key *b)
+vsfkey_openflow10_equal(const struct vsfkey_openflow10 *a, const struct vsfkey_openflow10 *b)
{
return !memcmp(a, b, sizeof *a);
}
static inline size_t
-odp_flow_key_hash(const struct odp_flow_key *flow, uint32_t basis)
+vsfkey_openflow10_hash(const struct vsfkey_openflow10 *flow, uint32_t basis)
{
BUILD_ASSERT_DECL(!(sizeof *flow % sizeof(uint32_t)));
return hash_words((const uint32_t *) flow,
diff --git a/lib/packets.h b/lib/packets.h
index af028eb..387b291 100644
--- a/lib/packets.h
+++ b/lib/packets.h
@@ -149,6 +149,12 @@ void compose_benign_packet(struct ofpbuf *, const char *tag,
&(ea)[0], &(ea)[1], &(ea)[2], &(ea)[3], &(ea)[4], &(ea)[5]
#define ETH_ADDR_SCAN_COUNT 6
+/* Values below this value are 802.3 packets and the two bytes following MAC
+ * addresses are used as a frame length. Otherwise, the two bytes are used as
+ * the Ethernet type.
+ */
+#define ETH_TYPE_MIN 0x0600
+
#define ETH_TYPE_IP 0x0800
#define ETH_TYPE_ARP 0x0806
#define ETH_TYPE_VLAN 0x8100
diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c
index 6b4f4a0..9caf216 100644
--- a/ofproto/ofproto.c
+++ b/ofproto/ofproto.c
@@ -2081,7 +2081,7 @@ do_put_flow(struct ofproto *ofproto, struct rule *rule, int flags,
struct odp_flow_put *put)
{
memset(&put->flow.stats, 0, sizeof put->flow.stats);
- odp_flow_key_from_flow(&put->flow.key, &rule->cr.flow);
+ vsfkey_openflow10_from_flow(&put->flow.key, &rule->cr.flow);
put->flow.actions = rule->odp_actions;
put->flow.n_actions = rule->n_odp_actions;
put->flow.flags = 0;
@@ -2177,7 +2177,7 @@ rule_uninstall(struct ofproto *p, struct rule *rule)
if (rule->installed) {
struct odp_flow odp_flow;
- odp_flow_key_from_flow(&odp_flow.key, &rule->cr.flow);
+ vsfkey_openflow10_from_flow(&odp_flow.key, &rule->cr.flow);
odp_flow.actions = NULL;
odp_flow.n_actions = 0;
odp_flow.flags = 0;
@@ -3135,12 +3135,13 @@ query_stats(struct ofproto *p, struct rule *rule,
if (rule->cr.wc.wildcards) {
size_t i = 0;
LIST_FOR_EACH (subrule, struct rule, list, &rule->list) {
- odp_flow_key_from_flow(&odp_flows[i++].key, &subrule->cr.flow);
+ vsfkey_openflow10_from_flow(&odp_flows[i++].key,
+ &subrule->cr.flow);
packet_count += subrule->packet_count;
byte_count += subrule->byte_count;
}
} else {
- odp_flow_key_from_flow(&odp_flows[0].key, &rule->cr.flow);
+ vsfkey_openflow10_from_flow(&odp_flows[0].key, &rule->cr.flow);
}
/* Fetch up-to-date statistics from the datapath and add them in. */
@@ -4323,7 +4324,7 @@ active_timeout(struct ofproto *ofproto, struct rule *rule)
/* Get updated flow stats. */
memset(&odp_flow, 0, sizeof odp_flow);
if (rule->installed) {
- odp_flow_key_from_flow(&odp_flow.key, &rule->cr.flow);
+ vsfkey_openflow10_from_flow(&odp_flow.key, &rule->cr.flow);
odp_flow.flags = ODPFF_ZERO_TCP_FLAGS;
dpif_flow_get(ofproto->dpif, &odp_flow);
@@ -4366,7 +4367,7 @@ update_used(struct ofproto *p)
struct rule *rule;
struct flow flow;
- odp_flow_key_to_flow(&f->key, &flow);
+ vsfkey_openflow10_to_flow(&f->key, &flow);
rule = rule_from_cls_rule(
classifier_find_rule_exactly(&p->cls, &flow, 0, UINT16_MAX));
--
1.7.1
More information about the dev
mailing list