aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2013-03-17 12:58:47 -0400
committerDavid S. Miller <davem@davemloft.net>2013-03-17 12:58:47 -0400
commit86feff3f3eb643cc5735d414e46a8201a8c67b8f (patch)
tree45e344303aec36f5c30456e0c7f3c38161ace7a5
parent1f9061d27d3d2028805549c4a306324a48209057 (diff)
parent4490108b4a5ada14c7be712260829faecc814ae5 (diff)
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/jesse/openvswitch
Conflicts: net/openvswitch/vport-internal_dev.c Jesse Gross says: ==================== A couple of minor enhancements for net-next/3.10. The largest is an extension to allow variable length metadata to be passed to userspace with packets. There is a merge conflict in net/openvswitch/vport-internal_dev.c: A existing commit modifies internal_dev_mac_addr() and a new commit deletes it. The new one is correct, so you can just remove that function. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/linux/openvswitch.h13
-rw-r--r--net/openvswitch/datapath.c13
-rw-r--r--net/openvswitch/datapath.h2
-rw-r--r--net/openvswitch/vport-internal_dev.c13
-rw-r--r--net/openvswitch/vport.h4
5 files changed, 19 insertions, 26 deletions
diff --git a/include/linux/openvswitch.h b/include/linux/openvswitch.h
index d42e174bd0c8..67d6c7b03581 100644
--- a/include/linux/openvswitch.h
+++ b/include/linux/openvswitch.h
@@ -94,7 +94,7 @@ struct ovs_vport_stats {
94}; 94};
95 95
96/* Fixed logical ports. */ 96/* Fixed logical ports. */
97#define OVSP_LOCAL ((__u16)0) 97#define OVSP_LOCAL ((__u32)0)
98 98
99/* Packet transfer. */ 99/* Packet transfer. */
100 100
@@ -127,7 +127,8 @@ enum ovs_packet_cmd {
127 * for %OVS_PACKET_CMD_EXECUTE. It has nested %OVS_ACTION_ATTR_* attributes. 127 * for %OVS_PACKET_CMD_EXECUTE. It has nested %OVS_ACTION_ATTR_* attributes.
128 * @OVS_PACKET_ATTR_USERDATA: Present for an %OVS_PACKET_CMD_ACTION 128 * @OVS_PACKET_ATTR_USERDATA: Present for an %OVS_PACKET_CMD_ACTION
129 * notification if the %OVS_ACTION_ATTR_USERSPACE action specified an 129 * notification if the %OVS_ACTION_ATTR_USERSPACE action specified an
130 * %OVS_USERSPACE_ATTR_USERDATA attribute. 130 * %OVS_USERSPACE_ATTR_USERDATA attribute, with the same length and content
131 * specified there.
131 * 132 *
132 * These attributes follow the &struct ovs_header within the Generic Netlink 133 * These attributes follow the &struct ovs_header within the Generic Netlink
133 * payload for %OVS_PACKET_* commands. 134 * payload for %OVS_PACKET_* commands.
@@ -137,7 +138,7 @@ enum ovs_packet_attr {
137 OVS_PACKET_ATTR_PACKET, /* Packet data. */ 138 OVS_PACKET_ATTR_PACKET, /* Packet data. */
138 OVS_PACKET_ATTR_KEY, /* Nested OVS_KEY_ATTR_* attributes. */ 139 OVS_PACKET_ATTR_KEY, /* Nested OVS_KEY_ATTR_* attributes. */
139 OVS_PACKET_ATTR_ACTIONS, /* Nested OVS_ACTION_ATTR_* attributes. */ 140 OVS_PACKET_ATTR_ACTIONS, /* Nested OVS_ACTION_ATTR_* attributes. */
140 OVS_PACKET_ATTR_USERDATA, /* u64 OVS_ACTION_ATTR_USERSPACE arg. */ 141 OVS_PACKET_ATTR_USERDATA, /* OVS_ACTION_ATTR_USERSPACE arg. */
141 __OVS_PACKET_ATTR_MAX 142 __OVS_PACKET_ATTR_MAX
142}; 143};
143 144
@@ -389,13 +390,13 @@ enum ovs_sample_attr {
389 * enum ovs_userspace_attr - Attributes for %OVS_ACTION_ATTR_USERSPACE action. 390 * enum ovs_userspace_attr - Attributes for %OVS_ACTION_ATTR_USERSPACE action.
390 * @OVS_USERSPACE_ATTR_PID: u32 Netlink PID to which the %OVS_PACKET_CMD_ACTION 391 * @OVS_USERSPACE_ATTR_PID: u32 Netlink PID to which the %OVS_PACKET_CMD_ACTION
391 * message should be sent. Required. 392 * message should be sent. Required.
392 * @OVS_USERSPACE_ATTR_USERDATA: If present, its u64 argument is copied to the 393 * @OVS_USERSPACE_ATTR_USERDATA: If present, its variable-length argument is
393 * %OVS_PACKET_CMD_ACTION message as %OVS_PACKET_ATTR_USERDATA, 394 * copied to the %OVS_PACKET_CMD_ACTION message as %OVS_PACKET_ATTR_USERDATA.
394 */ 395 */
395enum ovs_userspace_attr { 396enum ovs_userspace_attr {
396 OVS_USERSPACE_ATTR_UNSPEC, 397 OVS_USERSPACE_ATTR_UNSPEC,
397 OVS_USERSPACE_ATTR_PID, /* u32 Netlink PID to receive upcalls. */ 398 OVS_USERSPACE_ATTR_PID, /* u32 Netlink PID to receive upcalls. */
398 OVS_USERSPACE_ATTR_USERDATA, /* u64 optional user-specified cookie. */ 399 OVS_USERSPACE_ATTR_USERDATA, /* Optional user-specified cookie. */
399 __OVS_USERSPACE_ATTR_MAX 400 __OVS_USERSPACE_ATTR_MAX
400}; 401};
401 402
diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
index e87a26506dba..43b4ac1bcd10 100644
--- a/net/openvswitch/datapath.c
+++ b/net/openvswitch/datapath.c
@@ -369,8 +369,8 @@ static int queue_userspace_packet(struct net *net, int dp_ifindex,
369 len = sizeof(struct ovs_header); 369 len = sizeof(struct ovs_header);
370 len += nla_total_size(skb->len); 370 len += nla_total_size(skb->len);
371 len += nla_total_size(FLOW_BUFSIZE); 371 len += nla_total_size(FLOW_BUFSIZE);
372 if (upcall_info->cmd == OVS_PACKET_CMD_ACTION) 372 if (upcall_info->userdata)
373 len += nla_total_size(8); 373 len += NLA_ALIGN(upcall_info->userdata->nla_len);
374 374
375 user_skb = genlmsg_new(len, GFP_ATOMIC); 375 user_skb = genlmsg_new(len, GFP_ATOMIC);
376 if (!user_skb) { 376 if (!user_skb) {
@@ -387,8 +387,9 @@ static int queue_userspace_packet(struct net *net, int dp_ifindex,
387 nla_nest_end(user_skb, nla); 387 nla_nest_end(user_skb, nla);
388 388
389 if (upcall_info->userdata) 389 if (upcall_info->userdata)
390 nla_put_u64(user_skb, OVS_PACKET_ATTR_USERDATA, 390 __nla_put(user_skb, OVS_PACKET_ATTR_USERDATA,
391 nla_get_u64(upcall_info->userdata)); 391 nla_len(upcall_info->userdata),
392 nla_data(upcall_info->userdata));
392 393
393 nla = __nla_reserve(user_skb, OVS_PACKET_ATTR_PACKET, skb->len); 394 nla = __nla_reserve(user_skb, OVS_PACKET_ATTR_PACKET, skb->len);
394 395
@@ -543,7 +544,7 @@ static int validate_userspace(const struct nlattr *attr)
543{ 544{
544 static const struct nla_policy userspace_policy[OVS_USERSPACE_ATTR_MAX + 1] = { 545 static const struct nla_policy userspace_policy[OVS_USERSPACE_ATTR_MAX + 1] = {
545 [OVS_USERSPACE_ATTR_PID] = {.type = NLA_U32 }, 546 [OVS_USERSPACE_ATTR_PID] = {.type = NLA_U32 },
546 [OVS_USERSPACE_ATTR_USERDATA] = {.type = NLA_U64 }, 547 [OVS_USERSPACE_ATTR_USERDATA] = {.type = NLA_UNSPEC },
547 }; 548 };
548 struct nlattr *a[OVS_USERSPACE_ATTR_MAX + 1]; 549 struct nlattr *a[OVS_USERSPACE_ATTR_MAX + 1];
549 int error; 550 int error;
@@ -1627,7 +1628,7 @@ static struct vport *lookup_vport(struct net *net,
1627 1628
1628 vport = ovs_vport_rtnl_rcu(dp, port_no); 1629 vport = ovs_vport_rtnl_rcu(dp, port_no);
1629 if (!vport) 1630 if (!vport)
1630 return ERR_PTR(-ENOENT); 1631 return ERR_PTR(-ENODEV);
1631 return vport; 1632 return vport;
1632 } else 1633 } else
1633 return ERR_PTR(-EINVAL); 1634 return ERR_PTR(-EINVAL);
diff --git a/net/openvswitch/datapath.h b/net/openvswitch/datapath.h
index 031dfbf37c93..9125ad5c5aeb 100644
--- a/net/openvswitch/datapath.h
+++ b/net/openvswitch/datapath.h
@@ -119,7 +119,7 @@ struct ovs_skb_cb {
119 * struct dp_upcall - metadata to include with a packet to send to userspace 119 * struct dp_upcall - metadata to include with a packet to send to userspace
120 * @cmd: One of %OVS_PACKET_CMD_*. 120 * @cmd: One of %OVS_PACKET_CMD_*.
121 * @key: Becomes %OVS_PACKET_ATTR_KEY. Must be nonnull. 121 * @key: Becomes %OVS_PACKET_ATTR_KEY. Must be nonnull.
122 * @userdata: If nonnull, its u64 value is extracted and passed to userspace as 122 * @userdata: If nonnull, its variable-length value is passed to userspace as
123 * %OVS_PACKET_ATTR_USERDATA. 123 * %OVS_PACKET_ATTR_USERDATA.
124 * @pid: Netlink PID to which packet should be sent. If @pid is 0 then no 124 * @pid: Netlink PID to which packet should be sent. If @pid is 0 then no
125 * packet is sent and the packet is accounted in the datapath's @n_lost 125 * packet is sent and the packet is accounted in the datapath's @n_lost
diff --git a/net/openvswitch/vport-internal_dev.c b/net/openvswitch/vport-internal_dev.c
index 0531de6c7a4a..40f8a2489c90 100644
--- a/net/openvswitch/vport-internal_dev.c
+++ b/net/openvswitch/vport-internal_dev.c
@@ -63,16 +63,6 @@ static struct rtnl_link_stats64 *internal_dev_get_stats(struct net_device *netde
63 return stats; 63 return stats;
64} 64}
65 65
66static int internal_dev_mac_addr(struct net_device *dev, void *p)
67{
68 struct sockaddr *addr = p;
69
70 if (!is_valid_ether_addr(addr->sa_data))
71 return -EADDRNOTAVAIL;
72 memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);
73 return 0;
74}
75
76/* Called with rcu_read_lock_bh. */ 66/* Called with rcu_read_lock_bh. */
77static int internal_dev_xmit(struct sk_buff *skb, struct net_device *netdev) 67static int internal_dev_xmit(struct sk_buff *skb, struct net_device *netdev)
78{ 68{
@@ -126,7 +116,7 @@ static const struct net_device_ops internal_dev_netdev_ops = {
126 .ndo_open = internal_dev_open, 116 .ndo_open = internal_dev_open,
127 .ndo_stop = internal_dev_stop, 117 .ndo_stop = internal_dev_stop,
128 .ndo_start_xmit = internal_dev_xmit, 118 .ndo_start_xmit = internal_dev_xmit,
129 .ndo_set_mac_address = internal_dev_mac_addr, 119 .ndo_set_mac_address = eth_mac_addr,
130 .ndo_change_mtu = internal_dev_change_mtu, 120 .ndo_change_mtu = internal_dev_change_mtu,
131 .ndo_get_stats64 = internal_dev_get_stats, 121 .ndo_get_stats64 = internal_dev_get_stats,
132}; 122};
@@ -138,6 +128,7 @@ static void do_setup(struct net_device *netdev)
138 netdev->netdev_ops = &internal_dev_netdev_ops; 128 netdev->netdev_ops = &internal_dev_netdev_ops;
139 129
140 netdev->priv_flags &= ~IFF_TX_SKB_SHARING; 130 netdev->priv_flags &= ~IFF_TX_SKB_SHARING;
131 netdev->priv_flags |= IFF_LIVE_ADDR_CHANGE;
141 netdev->destructor = internal_dev_destructor; 132 netdev->destructor = internal_dev_destructor;
142 SET_ETHTOOL_OPS(netdev, &internal_dev_ethtool_ops); 133 SET_ETHTOOL_OPS(netdev, &internal_dev_ethtool_ops);
143 netdev->tx_queue_len = 0; 134 netdev->tx_queue_len = 0;
diff --git a/net/openvswitch/vport.h b/net/openvswitch/vport.h
index 3f7961ea3c56..aee7d43114c9 100644
--- a/net/openvswitch/vport.h
+++ b/net/openvswitch/vport.h
@@ -68,10 +68,10 @@ struct vport_err_stats {
68/** 68/**
69 * struct vport - one port within a datapath 69 * struct vport - one port within a datapath
70 * @rcu: RCU callback head for deferred destruction. 70 * @rcu: RCU callback head for deferred destruction.
71 * @port_no: Index into @dp's @ports array.
72 * @dp: Datapath to which this port belongs. 71 * @dp: Datapath to which this port belongs.
73 * @upcall_portid: The Netlink port to use for packets received on this port that 72 * @upcall_portid: The Netlink port to use for packets received on this port that
74 * miss the flow table. 73 * miss the flow table.
74 * @port_no: Index into @dp's @ports array.
75 * @hash_node: Element in @dev_table hash table in vport.c. 75 * @hash_node: Element in @dev_table hash table in vport.c.
76 * @dp_hash_node: Element in @datapath->ports hash table in datapath.c. 76 * @dp_hash_node: Element in @datapath->ports hash table in datapath.c.
77 * @ops: Class structure. 77 * @ops: Class structure.
@@ -81,9 +81,9 @@ struct vport_err_stats {
81 */ 81 */
82struct vport { 82struct vport {
83 struct rcu_head rcu; 83 struct rcu_head rcu;
84 u16 port_no;
85 struct datapath *dp; 84 struct datapath *dp;
86 u32 upcall_portid; 85 u32 upcall_portid;
86 u16 port_no;
87 87
88 struct hlist_node hash_node; 88 struct hlist_node hash_node;
89 struct hlist_node dp_hash_node; 89 struct hlist_node dp_hash_node;