mbox series

[net-next,0/9] genetlink: support per-command policy dump

Message ID 20201001183016.1259870-1-kuba@kernel.org
Headers show
Series genetlink: support per-command policy dump | expand

Message

Jakub Kicinski Oct. 1, 2020, 6:30 p.m. UTC
Hi!

The objective of this series is to dump ethtool policies
to be able to tell which flags are supported by the kernel.
Current release adds ETHTOOL_FLAG_STATS for dumping extra
stats, but because of strict checking we need to make sure
that the flag is actually supported before setting it in
a request.

Ethtool policies are per command, and so far only dumping
family policies was supported.

The series adds new set of "light" ops to genl families which
don't have all the callbacks, and won't have the policy.
Most of families are then moved to these ops. This gives
us 4096B in savings on an allyesconfig build (not counting
the growth that would have happened when policy is added):

     text       data       bss        dec       hex
244415581  227958581  78372980  550747142  20d3bc06
244415581  227962677  78372980  550751238  20d3cc06

Next 5 patches deal the dumping per-op policy.

v1:
 - replace remaining uses of "light" with "small" (patch 2)
 - fix dump (ops can't be on the stack there) (patch 2)
 - coding changes in patch 4
 - new patch 7
 - don't echo op in responses - to make dump all easier
   (patch 9)

Dave - this series will cause a very trivial conflict with
the patch I sent to net. Both sides add some kdoc to struct
genl_ops so we'll need to keep it all.  I'm sending this
already because I also need to restructure ethool policies
in time for 5.10 if we want to use it for the stats flag.

Jakub Kicinski (9):
  genetlink: reorg struct genl_family
  genetlink: add small version of ops
  genetlink: move to smaller ops wherever possible
  genetlink: add a structure for dump state
  genetlink: use .start callback for dumppolicy
  genetlink: bring back per op policy
  taskstats: move specifying netlink policy back to ops
  genetlink: use per-op policy for CTRL_CMD_GETPOLICY
  genetlink: allow dumping command-specific policy

 drivers/block/nbd.c                      |   6 +-
 drivers/net/gtp.c                        |   6 +-
 drivers/net/ieee802154/mac802154_hwsim.c |   6 +-
 drivers/net/macsec.c                     |   6 +-
 drivers/net/team/team.c                  |   6 +-
 drivers/net/wireless/mac80211_hwsim.c    |   6 +-
 drivers/target/target_core_user.c        |   6 +-
 drivers/thermal/thermal_netlink.c        |   8 +-
 fs/dlm/netlink.c                         |   6 +-
 include/net/genetlink.h                  |  67 +++++--
 include/net/netlink.h                    |   9 +-
 include/uapi/linux/genetlink.h           |   1 +
 kernel/taskstats.c                       |  36 +---
 net/batman-adv/netlink.c                 |   6 +-
 net/core/devlink.c                       |   6 +-
 net/core/drop_monitor.c                  |   6 +-
 net/hsr/hsr_netlink.c                    |   6 +-
 net/ieee802154/netlink.c                 |   6 +-
 net/ipv4/fou.c                           |   6 +-
 net/ipv4/tcp_metrics.c                   |   6 +-
 net/l2tp/l2tp_netlink.c                  |   6 +-
 net/mptcp/pm_netlink.c                   |   6 +-
 net/ncsi/ncsi-netlink.c                  |   6 +-
 net/netfilter/ipvs/ip_vs_ctl.c           |   6 +-
 net/netlabel/netlabel_calipso.c          |   6 +-
 net/netlabel/netlabel_cipso_v4.c         |   6 +-
 net/netlabel/netlabel_mgmt.c             |   6 +-
 net/netlabel/netlabel_unlabeled.c        |   6 +-
 net/netlink/genetlink.c                  | 228 ++++++++++++++++-------
 net/netlink/policy.c                     |  29 +--
 net/openvswitch/conntrack.c              |   6 +-
 net/openvswitch/datapath.c               |  24 +--
 net/openvswitch/meter.c                  |   6 +-
 net/psample/psample.c                    |   6 +-
 net/tipc/netlink_compat.c                |   6 +-
 net/wimax/stack.c                        |   6 +-
 net/wireless/nl80211.c                   |   5 +
 37 files changed, 343 insertions(+), 232 deletions(-)

Comments

Johannes Berg Oct. 1, 2020, 9:10 p.m. UTC | #1
On Thu, 2020-10-01 at 14:09 -0700, Jakub Kicinski wrote:
> On Thu, 01 Oct 2020 22:55:09 +0200 Johannes Berg wrote:
> > On Thu, 2020-10-01 at 11:30 -0700, Jakub Kicinski wrote:
> > > Wire up per-op policy for CTRL_CMD_GETPOLICY.
> > > This saves us a call to genlmsg_parse() and will soon allow
> > > dumping this policy.  
> > 
> > Hmm. Probably should've asked this before - I think the code makes
> > perfect sense, but I'm not sure how "this" follows?
> > 
> > I mean, we could've saved the genlmsg_parse() call before, with much the
> > same patch, having the per-op policy doesn't really have any bearing for
> > that? It was just using a different policy - the family one - instead of
> > the per-op one, but ...
> > 
> > Am I missing something?
> 
> Hm, not as far as I can tell, I was probably typing out the message
> fast cause the commit is kinda obivious.
> 
> Looking at the code again now I can't tell why it was calling
> genlmsg_parse() in the first place. LMK if you remember if there 
> was a reason.

Quite possibly it was just old code? I _think_, but didn't check now,
that the parsing for dumpit was added later. Hence the "don't parse"
validate flag, because it wasn't always done and thus would've accepted
any kind of junk as input ...

johannes