ofproto: Implement asynchronous OFPT_FLOW_MOD commands.
[openvswitch] / datapath / datapath.c
index 72801224984c94a8954a5473b5e3110ba004dff9..534ab9143c866180d9a8807da18894b39dc3e78a 100644 (file)
 #include "vlan.h"
 #include "vport-internal_dev.h"
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18) || \
+    LINUX_VERSION_CODE > KERNEL_VERSION(2,6,39)
+#error Kernels before 2.6.18 or after 2.6.39 are not supported by this version of Open vSwitch.
+#endif
+
 int (*dp_ioctl_hook)(struct net_device *dev, struct ifreq *rq, int cmd);
 EXPORT_SYMBOL(dp_ioctl_hook);
 
@@ -565,7 +570,6 @@ static int validate_actions(const struct nlattr *attr)
                        [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);
 
@@ -587,7 +591,6 @@ static int validate_actions(const struct nlattr *attr)
                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;
 
@@ -655,7 +658,8 @@ static int odp_packet_cmd_execute(struct sk_buff *skb, struct genl_info *info)
        int key_len;
 
        err = -EINVAL;
-       if (!a[ODP_PACKET_ATTR_PACKET] || !a[ODP_PACKET_ATTR_ACTIONS] ||
+       if (!a[ODP_PACKET_ATTR_PACKET] || !a[ODP_PACKET_ATTR_KEY] ||
+           !a[ODP_PACKET_ATTR_ACTIONS] ||
            nla_len(a[ODP_PACKET_ATTR_PACKET]) < ETH_HLEN)
                goto err;
 
@@ -694,6 +698,12 @@ static int odp_packet_cmd_execute(struct sk_buff *skb, struct genl_info *info)
                goto err_flow_put;
        flow->tbl_node.hash = flow_hash(&flow->key, key_len);
 
+       err = flow_metadata_from_nlattrs(&flow->key.eth.in_port,
+                                        &flow->key.eth.tun_id,
+                                        a[ODP_PACKET_ATTR_KEY]);
+       if (err)
+               goto err_flow_put;
+
        acts = flow_actions_alloc(a[ODP_PACKET_ATTR_ACTIONS]);
        err = PTR_ERR(acts);
        if (IS_ERR(acts))
@@ -725,6 +735,7 @@ err:
 
 static const struct nla_policy packet_policy[ODP_PACKET_ATTR_MAX + 1] = {
        [ODP_PACKET_ATTR_PACKET] = { .type = NLA_UNSPEC },
+       [ODP_PACKET_ATTR_KEY] = { .type = NLA_NESTED },
        [ODP_PACKET_ATTR_ACTIONS] = { .type = NLA_NESTED },
 };