All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ronen Arad <ronen.arad@intel.com>
To: netdev@vger.kernel.org
Cc: Ronen Arad <ronen.arad@intel.com>
Subject: [PATCH net-next 3/4] rtnetlink: Prefer filtering-aware af sizing
Date: Tue, 13 Oct 2015 22:58:33 -0700	[thread overview]
Message-ID: <1444802314-28830-4-git-send-email-ronen.arad@intel.com> (raw)
In-Reply-To: <1444802314-28830-1-git-send-email-ronen.arad@intel.com>

Add ext_filter_mask arg to rtnl_link_get_af_size().
rtnl_link_get_af_size() will prefer filtering-aware af sizing when
provided by an address family. It falls back to get_link_af_size for
other families.

Signed-off-by: Ronen Arad <ronen.arad@intel.com>
---
 net/core/rtnetlink.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 2477595..dd7cda7 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -497,7 +497,8 @@ void rtnl_af_unregister(struct rtnl_af_ops *ops)
 }
 EXPORT_SYMBOL_GPL(rtnl_af_unregister);
 
-static size_t rtnl_link_get_af_size(const struct net_device *dev)
+static size_t rtnl_link_get_af_size(const struct net_device *dev,
+				    u32 ext_filter_mask)
 {
 	struct rtnl_af_ops *af_ops;
 	size_t size;
@@ -506,7 +507,12 @@ static size_t rtnl_link_get_af_size(const struct net_device *dev)
 	size = nla_total_size(sizeof(struct nlattr));
 
 	list_for_each_entry(af_ops, &rtnl_af_ops, list) {
-		if (af_ops->get_link_af_size) {
+		/* Prefer filtering-aware af sizing when available */
+		if (af_ops->get_link_af_size_filtered) {
+			/* AF_* + nested data */
+			size += nla_total_size(sizeof(struct nlattr)) +
+				af_ops->get_link_af_size_filtered(dev, ext_filter_mask);
+		} else if (af_ops->get_link_af_size) {
 			/* AF_* + nested data */
 			size += nla_total_size(sizeof(struct nlattr)) +
 				af_ops->get_link_af_size(dev);
@@ -900,7 +906,7 @@ static noinline size_t if_nlmsg_size(const struct net_device *dev,
 	       + rtnl_vfinfo_size(dev, ext_filter_mask) /* IFLA_VFINFO_LIST */
 	       + rtnl_port_size(dev, ext_filter_mask) /* IFLA_VF_PORTS + IFLA_PORT_SELF */
 	       + rtnl_link_get_size(dev) /* IFLA_LINKINFO */
-	       + rtnl_link_get_af_size(dev) /* IFLA_AF_SPEC */
+	       + rtnl_link_get_af_size(dev, ext_filter_mask) /* IFLA_AF_SPEC */
 	       + nla_total_size(MAX_PHYS_ITEM_ID_LEN) /* IFLA_PHYS_PORT_ID */
 	       + nla_total_size(MAX_PHYS_ITEM_ID_LEN) /* IFLA_PHYS_SWITCH_ID */
 	       + nla_total_size(1); /* IFLA_PROTO_DOWN */
-- 
2.1.0

  parent reply	other threads:[~2015-10-14  5:59 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-14  5:58 [PATCH net-next 0/4] Rightsize IFLA_AF_SPEC size calculation Ronen Arad
2015-10-14  5:58 ` [PATCH net-next 1/4] rtnetlink: Add get_link_af_size_filtered to rtnl_af_ops Ronen Arad
2015-10-14  9:55   ` Jiri Benc
2015-10-14 14:46     ` Arad, Ronen
2015-10-14  5:58 ` [PATCH net-next 2/4] bridge: br_af_ops add br_get_link_af_size_filtered Ronen Arad
2015-10-14  5:58 ` Ronen Arad [this message]
2015-10-14  5:58 ` [PATCH net-next 4/4] bridge: Remove br_get_link_af_size Ronen Arad
2015-10-14 15:51 ` [PATCH net-next v2] netlink: Rightsize IFLA_AF_SPEC size calculation Ronen Arad
2015-10-15  2:24   ` David Miller
2015-10-15  5:52     ` Arad, Ronen
2015-10-15  5:50   ` [PATCH net-next v3] " Ronen Arad
2015-10-15 13:02     ` David Miller
2015-10-19 16:23     ` Ronen Arad
2015-10-21  6:31       ` Samudrala, Sridhar
2015-10-22  2:15       ` David Miller
2015-10-15  1:44 ` [PATCH net-next 0/4] " David Miller
2015-10-15  1:32   ` Arad, Ronen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1444802314-28830-4-git-send-email-ronen.arad@intel.com \
    --to=ronen.arad@intel.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.