Subject: Re: [PATCH net-next v2 03/22] ovpn: add basic netlink support

From: kernel test robot <[email-masked]>
Date: Tue, 5 Mar 2024 18:49:49 +0800

Hi Antonio,

kernel test robot noticed the following build warnings:

[auto build test WARNING on net-next/main]

url:    https://github.com/intel-lab-lkp/linux/commits/Antonio-Quartulli/netlink-add-NLA_POLICY_MAX_LEN-macro/20240304-232835
base:   net-next/main
patch link:    https://lore.kernel.org/r/20240304150914.11444-4-antonio%40openvpn.net
patch subject: [PATCH net-next v2 03/22] ovpn: add basic netlink support
config: sh-allmodconfig (https://download.01.org/0day-ci/archive/20240305/[email-masked]/config)
compiler: sh4-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240305/[email-masked]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email-masked]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email-masked]/

All warnings (new ones prefixed by >>):

>> drivers/net/ovpn/netlink.c:82: warning: Function parameter or struct member 'net' not described in 'ovpn_get_dev_from_attrs'
>> drivers/net/ovpn/netlink.c:82: warning: Function parameter or struct member 'attrs' not described in 'ovpn_get_dev_from_attrs'
>> drivers/net/ovpn/netlink.c:181: warning: Function parameter or struct member 'nb' not described in 'ovpn_nl_notify'
>> drivers/net/ovpn/netlink.c:181: warning: Function parameter or struct member 'state' not described in 'ovpn_nl_notify'
>> drivers/net/ovpn/netlink.c:181: warning: Function parameter or struct member '_notify' not described in 'ovpn_nl_notify'
>> drivers/net/ovpn/netlink.c:193: warning: Function parameter or struct member 'ovpn' not described in 'ovpn_nl_init'

vim +82 drivers/net/ovpn/netlink.c

    76	
    77	/**
    78	 * ovpn_get_dev_from_attrs() - retrieve the netdevice a netlink message is targeting
    79	 */
    80	static struct net_device *
    81	ovpn_get_dev_from_attrs(struct net *net, struct nlattr **attrs)
  > 82	{
    83		struct net_device *dev;
    84		int ifindex;
    85	
    86		if (!attrs[OVPN_A_IFINDEX])
    87			return ERR_PTR(-EINVAL);
    88	
    89		ifindex = nla_get_u32(attrs[OVPN_A_IFINDEX]);
    90	
    91		dev = dev_get_by_index(net, ifindex);
    92		if (!dev)
    93			return ERR_PTR(-ENODEV);
    94	
    95		if (!ovpn_dev_is_valid(dev))
    96			goto err_put_dev;
    97	
    98		return dev;
    99	
   100	err_put_dev:
   101		dev_put(dev);
   102	
   103		return ERR_PTR(-EINVAL);
   104	}
   105	
   106	/**
   107	 * ovpn_pre_doit() - Prepare ovpn genl doit request
   108	 * @ops: requested netlink operation
   109	 * @skb: Netlink message with request data
   110	 * @info: receiver information
   111	 *
   112	 * Return: 0 on success or negative error number in case of failure
   113	 */
   114	static int ovpn_pre_doit(const struct genl_split_ops *ops, struct sk_buff *skb,
   115				 struct genl_info *info)
   116	{
   117		struct net *net = genl_info_net(info);
   118		struct net_device *dev;
   119	
   120		/* the OVPN_CMD_NEW_IFACE command is different from the rest as it
   121		 * just expects an IFNAME, while all the others expect an IFINDEX
   122		 */
   123		if (info->genlhdr->cmd == OVPN_CMD_NEW_IFACE) {
   124			if (!info->attrs[OVPN_A_IFNAME]) {
   125				GENL_SET_ERR_MSG(info, "no interface name specified");
   126				return -EINVAL;
   127			}
   128			return 0;
   129		}
   130	
   131		dev = ovpn_get_dev_from_attrs(net, info->attrs);
   132		if (IS_ERR(dev))
   133			return PTR_ERR(dev);
   134	
   135		info->user_ptr[0] = netdev_priv(dev);
   136	
   137		return 0;
   138	}
   139	
   140	/**
   141	 * ovpn_post_doit() - complete ovpn genl doit request
   142	 * @ops: requested netlink operation
   143	 * @skb: Netlink message with request data
   144	 * @info: receiver information
   145	 */
   146	static void ovpn_post_doit(const struct genl_split_ops *ops, struct sk_buff *skb,
   147				   struct genl_info *info)
   148	{
   149		struct ovpn_struct *ovpn;
   150	
   151		ovpn = info->user_ptr[0];
   152		/* in case of OVPN_CMD_NEW_IFACE, there is no pre-stored device */
   153		if (ovpn)
   154			dev_put(ovpn->dev);
   155	}
   156	
   157	static const struct genl_small_ops ovpn_nl_ops[] = {
   158	};
   159	
   160	static struct genl_family ovpn_nl_family __ro_after_init = {
   161		.hdrsize = 0,
   162		.name = OVPN_NL_NAME,
   163		.version = 1,
   164		.maxattr = NUM_OVPN_A + 1,
   165		.policy = ovpn_nl_policy,
   166		.netnsok = true,
   167		.pre_doit = ovpn_pre_doit,
   168		.post_doit = ovpn_post_doit,
   169		.module = THIS_MODULE,
   170		.small_ops = ovpn_nl_ops,
   171		.n_small_ops = ARRAY_SIZE(ovpn_nl_ops),
   172		.mcgrps = ovpn_nl_mcgrps,
   173		.n_mcgrps = ARRAY_SIZE(ovpn_nl_mcgrps),
   174	};
   175	
   176	/**
   177	 * ovpn_nl_notify() - react to openvpn userspace process exit
   178	 */
   179	static int ovpn_nl_notify(struct notifier_block *nb, unsigned long state,
   180				  void *_notify)
 > 181	{
   182		return NOTIFY_DONE;
   183	}
   184	
   185	static struct notifier_block ovpn_nl_notifier = {
   186		.notifier_call = ovpn_nl_notify,
   187	};
   188	
   189	/**
   190	 * ovpn_nl_init() - perform any ovpn specific netlink initialization
   191	 */
   192	int ovpn_nl_init(struct ovpn_struct *ovpn)
 > 193	{
   194		return 0;
   195	}
   196	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki