diff options
author | David S. Miller <davem@davemloft.net> | 2014-01-06 19:48:38 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-01-06 19:48:38 -0500 |
commit | 39b6b2992f9dc65d1de5c66e7ec2271b8a5fac33 (patch) | |
tree | c0fc4e2be0429bb4d7643e6b6f8f5a56212f9284 /net/netlink | |
parent | 56a4342dfe3145cd66f766adccb28fd9b571606d (diff) | |
parent | 443cd88c8a31379e95326428bbbd40af25c1d440 (diff) |
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/jesse/openvswitch
Jesse Gross says:
====================
[GIT net-next] Open vSwitch
Open vSwitch changes for net-next/3.14. Highlights are:
* Performance improvements in the mechanism to get packets to userspace
using memory mapped netlink and skb zero copy where appropriate.
* Per-cpu flow stats in situations where flows are likely to be shared
across CPUs. Standard flow stats are used in other situations to save
memory and allocation time.
* A handful of code cleanups and rationalization.
====================
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/netlink')
-rw-r--r-- | net/netlink/af_netlink.c | 4 | ||||
-rw-r--r-- | net/netlink/genetlink.c | 21 |
2 files changed, 25 insertions, 0 deletions
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c index b077b90c1254..34a656d90175 100644 --- a/net/netlink/af_netlink.c +++ b/net/netlink/af_netlink.c | |||
@@ -1773,6 +1773,9 @@ struct sk_buff *netlink_alloc_skb(struct sock *ssk, unsigned int size, | |||
1773 | if (ring->pg_vec == NULL) | 1773 | if (ring->pg_vec == NULL) |
1774 | goto out_put; | 1774 | goto out_put; |
1775 | 1775 | ||
1776 | if (ring->frame_size - NL_MMAP_HDRLEN < size) | ||
1777 | goto out_put; | ||
1778 | |||
1776 | skb = alloc_skb_head(gfp_mask); | 1779 | skb = alloc_skb_head(gfp_mask); |
1777 | if (skb == NULL) | 1780 | if (skb == NULL) |
1778 | goto err1; | 1781 | goto err1; |
@@ -1782,6 +1785,7 @@ struct sk_buff *netlink_alloc_skb(struct sock *ssk, unsigned int size, | |||
1782 | if (ring->pg_vec == NULL) | 1785 | if (ring->pg_vec == NULL) |
1783 | goto out_free; | 1786 | goto out_free; |
1784 | 1787 | ||
1788 | /* check again under lock */ | ||
1785 | maxlen = ring->frame_size - NL_MMAP_HDRLEN; | 1789 | maxlen = ring->frame_size - NL_MMAP_HDRLEN; |
1786 | if (maxlen < size) | 1790 | if (maxlen < size) |
1787 | goto out_free; | 1791 | goto out_free; |
diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c index 713671ae45af..b1dcdb932a86 100644 --- a/net/netlink/genetlink.c +++ b/net/netlink/genetlink.c | |||
@@ -461,6 +461,26 @@ int genl_unregister_family(struct genl_family *family) | |||
461 | EXPORT_SYMBOL(genl_unregister_family); | 461 | EXPORT_SYMBOL(genl_unregister_family); |
462 | 462 | ||
463 | /** | 463 | /** |
464 | * genlmsg_new_unicast - Allocate generic netlink message for unicast | ||
465 | * @payload: size of the message payload | ||
466 | * @info: information on destination | ||
467 | * @flags: the type of memory to allocate | ||
468 | * | ||
469 | * Allocates a new sk_buff large enough to cover the specified payload | ||
470 | * plus required Netlink headers. Will check receiving socket for | ||
471 | * memory mapped i/o capability and use it if enabled. Will fall back | ||
472 | * to non-mapped skb if message size exceeds the frame size of the ring. | ||
473 | */ | ||
474 | struct sk_buff *genlmsg_new_unicast(size_t payload, struct genl_info *info, | ||
475 | gfp_t flags) | ||
476 | { | ||
477 | size_t len = nlmsg_total_size(genlmsg_total_size(payload)); | ||
478 | |||
479 | return netlink_alloc_skb(info->dst_sk, len, info->snd_portid, flags); | ||
480 | } | ||
481 | EXPORT_SYMBOL_GPL(genlmsg_new_unicast); | ||
482 | |||
483 | /** | ||
464 | * genlmsg_put - Add generic netlink header to netlink message | 484 | * genlmsg_put - Add generic netlink header to netlink message |
465 | * @skb: socket buffer holding the message | 485 | * @skb: socket buffer holding the message |
466 | * @portid: netlink portid the message is addressed to | 486 | * @portid: netlink portid the message is addressed to |
@@ -600,6 +620,7 @@ static int genl_family_rcv_msg(struct genl_family *family, | |||
600 | info.genlhdr = nlmsg_data(nlh); | 620 | info.genlhdr = nlmsg_data(nlh); |
601 | info.userhdr = nlmsg_data(nlh) + GENL_HDRLEN; | 621 | info.userhdr = nlmsg_data(nlh) + GENL_HDRLEN; |
602 | info.attrs = attrbuf; | 622 | info.attrs = attrbuf; |
623 | info.dst_sk = skb->sk; | ||
603 | genl_info_net_set(&info, net); | 624 | genl_info_net_set(&info, net); |
604 | memset(&info.user_ptr, 0, sizeof(info.user_ptr)); | 625 | memset(&info.user_ptr, 0, sizeof(info.user_ptr)); |
605 | 626 | ||