meta-flow: Correctly set destination MAC in mf_set_flow_value().
[sliver-openvswitch.git] / datapath / vport-patch.c
index 7cb221e..53b24b0 100644 (file)
@@ -1,9 +1,19 @@
 /*
- * Copyright (c) 2010, 2011 Nicira Networks.
- * Distributed under the terms of the GNU GPL version 2.
+ * Copyright (c) 2007-2011 Nicira Networks.
  *
- * Significant portions of this file may be copied from parts of the Linux
- * kernel, by Linus Torvalds and others.
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA
  */
 
 #include <linux/dcache.h>
@@ -41,7 +51,7 @@ static struct hlist_head *peer_table;
 
 static void update_peers(const char *name, struct vport *);
 
-static inline struct patch_vport *patch_vport_priv(const struct vport *vport)
+static struct patch_vport *patch_vport_priv(const struct vport *vport)
 {
        return vport_priv(vport);
 }
@@ -85,9 +95,9 @@ static void patch_exit(void)
        kfree(peer_table);
 }
 
-static const struct nla_policy patch_policy[ODP_PATCH_ATTR_MAX + 1] = {
+static const struct nla_policy patch_policy[OVS_PATCH_ATTR_MAX + 1] = {
 #ifdef HAVE_NLA_NUL_STRING
-       [ODP_PATCH_ATTR_PEER] = { .type = NLA_NUL_STRING, .len = IFNAMSIZ - 1 },
+       [OVS_PATCH_ATTR_PEER] = { .type = NLA_NUL_STRING, .len = IFNAMSIZ - 1 },
 #endif
 };
 
@@ -95,22 +105,22 @@ static int patch_set_config(struct vport *vport, const struct nlattr *options,
                            struct patch_config *patchconf)
 {
        struct patch_vport *patch_vport = patch_vport_priv(vport);
-       struct nlattr *a[ODP_PATCH_ATTR_MAX + 1];
+       struct nlattr *a[OVS_PATCH_ATTR_MAX + 1];
        const char *peer_name;
        int err;
 
        if (!options)
                return -EINVAL;
 
-       err = nla_parse_nested(a, ODP_PATCH_ATTR_MAX, options, patch_policy);
+       err = nla_parse_nested(a, OVS_PATCH_ATTR_MAX, options, patch_policy);
        if (err)
                return err;
 
-       if (!a[ODP_PATCH_ATTR_PEER] ||
-           CHECK_NUL_STRING(a[ODP_PATCH_ATTR_PEER], IFNAMSIZ - 1))
+       if (!a[OVS_PATCH_ATTR_PEER] ||
+           CHECK_NUL_STRING(a[OVS_PATCH_ATTR_PEER], IFNAMSIZ - 1))
                return -EINVAL;
 
-       peer_name = nla_data(a[ODP_PATCH_ATTR_PEER]);
+       peer_name = nla_data(a[OVS_PATCH_ATTR_PEER]);
        if (!strcmp(patch_vport->name, peer_name))
                return -EINVAL;
 
@@ -127,7 +137,8 @@ static struct vport *patch_create(const struct vport_parms *parms)
        struct patch_config *patchconf;
        int err;
 
-       vport = vport_alloc(sizeof(struct patch_vport), &patch_vport_ops, parms);
+       vport = ovs_vport_alloc(sizeof(struct patch_vport),
+                               &ovs_patch_vport_ops, parms);
        if (IS_ERR(vport)) {
                err = PTR_ERR(vport);
                goto error;
@@ -147,13 +158,13 @@ static struct vport *patch_create(const struct vport_parms *parms)
        if (err)
                goto error_free_patchconf;
 
-       vport_gen_rand_ether_addr(patchconf->eth_addr);
+       random_ether_addr(patchconf->eth_addr);
 
        rcu_assign_pointer(patch_vport->patchconf, patchconf);
 
        peer_name = patchconf->peer_name;
        hlist_add_head(&patch_vport->hash_node, hash_bucket(peer_name));
-       rcu_assign_pointer(patch_vport->peer, vport_locate(peer_name));
+       rcu_assign_pointer(patch_vport->peer, ovs_vport_locate(peer_name));
        update_peers(patch_vport->name, vport);
 
        return vport;
@@ -161,7 +172,7 @@ static struct vport *patch_create(const struct vport_parms *parms)
 error_free_patchconf:
        kfree(patchconf);
 error_free_vport:
-       vport_free(vport);
+       ovs_vport_free(vport);
 error:
        return ERR_PTR(err);
 }
@@ -172,18 +183,16 @@ static void free_port_rcu(struct rcu_head *rcu)
                                          struct patch_vport, rcu);
 
        kfree((struct patch_config __force *)patch_vport->patchconf);
-       vport_free(vport_from_priv(patch_vport));
+       ovs_vport_free(vport_from_priv(patch_vport));
 }
 
-static int patch_destroy(struct vport *vport)
+static void patch_destroy(struct vport *vport)
 {
        struct patch_vport *patch_vport = patch_vport_priv(vport);
 
        update_peers(patch_vport->name, NULL);
        hlist_del(&patch_vport->hash_node);
        call_rcu(&patch_vport->rcu, free_port_rcu);
-
-       return 0;
 }
 
 static int patch_set_options(struct vport *vport, struct nlattr *options)
@@ -207,7 +216,7 @@ static int patch_set_options(struct vport *vport, struct nlattr *options)
 
        hlist_del(&patch_vport->hash_node);
 
-       rcu_assign_pointer(patch_vport->peer, vport_locate(patchconf->peer_name));
+       rcu_assign_pointer(patch_vport->peer, ovs_vport_locate(patchconf->peer_name));
        hlist_add_head(&patch_vport->hash_node, hash_bucket(patchconf->peer_name));
 
        return 0;
@@ -267,7 +276,7 @@ static int patch_get_options(const struct vport *vport, struct sk_buff *skb)
        struct patch_vport *patch_vport = patch_vport_priv(vport);
        struct patch_config *patchconf = rcu_dereference_rtnl(patch_vport->patchconf);
 
-       return nla_put_string(skb, ODP_PATCH_ATTR_PEER, patchconf->peer_name);
+       return nla_put_string(skb, OVS_PATCH_ATTR_PEER, patchconf->peer_name);
 }
 
 static int patch_send(struct vport *vport, struct sk_buff *skb)
@@ -278,18 +287,17 @@ static int patch_send(struct vport *vport, struct sk_buff *skb)
 
        if (!peer) {
                kfree_skb(skb);
-               vport_record_error(vport, VPORT_E_TX_DROPPED);
+               ovs_vport_record_error(vport, VPORT_E_TX_DROPPED);
 
                return 0;
        }
 
-       vport_receive(peer, skb);
+       ovs_vport_receive(peer, skb);
        return skb_len;
 }
 
-const struct vport_ops patch_vport_ops = {
-       .type           = ODP_VPORT_TYPE_PATCH,
-       .flags          = VPORT_F_GEN_STATS,
+const struct vport_ops ovs_patch_vport_ops = {
+       .type           = OVS_VPORT_TYPE_PATCH,
        .init           = patch_init,
        .exit           = patch_exit,
        .create         = patch_create,
@@ -299,8 +307,8 @@ const struct vport_ops patch_vport_ops = {
        .get_addr       = patch_get_addr,
        .get_options    = patch_get_options,
        .set_options    = patch_set_options,
-       .get_dev_flags  = vport_gen_get_dev_flags,
-       .is_running     = vport_gen_is_running,
-       .get_operstate  = vport_gen_get_operstate,
+       .get_dev_flags  = ovs_vport_gen_get_dev_flags,
+       .is_running     = ovs_vport_gen_is_running,
+       .get_operstate  = ovs_vport_gen_get_operstate,
        .send           = patch_send,
 };