b.a.t.m.a.n.lists.open-mesh.org archive mirror
 help / color / mirror / Atom feed
From: Jiri Pirko <jiri@resnulli.us>
To: Sven Eckelmann <sven@narfation.org>
Cc: b.a.t.m.a.n@lists.open-mesh.org, Jiri Pirko <jiri@mellanox.com>,
	netdev@vger.kernel.org
Subject: Re: [B.A.T.M.A.N.] [RFC v4 04/19] batman-adv: Prepare framework for vlan genl config
Date: Mon, 21 Jan 2019 10:44:30 +0100	[thread overview]
Message-ID: <20190121094430.GC2228@nanopsycho> (raw)
In-Reply-To: <20190119155626.6414-5-sven@narfation.org>

Sat, Jan 19, 2019 at 04:56:11PM CET, sven@narfation.org wrote:

[...]

>+/**
>+ * batadv_netlink_vlan_put() - Fill message with vlan attributes
>+ * @msg: Netlink message to dump into
>+ * @bat_priv: the bat priv with all the soft interface information
>+ * @vlan: vlan which was modified
>+ * @cmd: type of message to generate
>+ * @portid: Port making netlink request
>+ * @seq: sequence number for message
>+ * @flags: Additional flags for message
>+ *
>+ * Return: 0 on success or negative error number in case of failure
>+ */
>+static int batadv_netlink_vlan_put(struct sk_buff *msg,
>+				   struct batadv_priv *bat_priv,
>+				   struct batadv_softif_vlan *vlan,
>+				   enum batadv_nl_commands cmd,
>+				   u32 portid, u32 seq, int flags)
>+{
>+	void *hdr;
>+
>+	hdr = genlmsg_put(msg, portid, seq, &batadv_netlink_family, flags, cmd);
>+	if (!hdr)
>+		return -ENOBUFS;
>+
>+	if (nla_put_u32(msg, BATADV_ATTR_MESH_IFINDEX,
>+			bat_priv->soft_iface->ifindex))
>+		goto nla_put_failure;
>+
>+	if (nla_put_u32(msg, BATADV_ATTR_VLANID, vlan->vid & VLAN_VID_MASK))
>+		goto nla_put_failure;
>+
>+	genlmsg_end(msg, hdr);
>+	return 0;
>+
>+nla_put_failure:
>+	genlmsg_cancel(msg, hdr);
>+	return -EMSGSIZE;
>+}
>+
>+/**
>+ * batadv_netlink_notify_vlan() - send vlan attributes to listener
>+ * @bat_priv: the bat priv with all the soft interface information
>+ * @vlan: vlan which was modified
>+ *
>+ * Return: 0 on success, < 0 on error
>+ */
>+static int batadv_netlink_notify_vlan(struct batadv_priv *bat_priv,
>+				      struct batadv_softif_vlan *vlan)
>+{
>+	struct sk_buff *msg;
>+	int ret;
>+
>+	msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
>+	if (!msg)
>+		return -ENOMEM;
>+
>+	ret = batadv_netlink_vlan_put(msg, bat_priv, vlan,
>+				      BATADV_CMD_SET_VLAN, 0, 0, 0);
>+	if (ret < 0) {
>+		nlmsg_free(msg);
>+		return ret;
>+	}
>+
>+	genlmsg_multicast_netns(&batadv_netlink_family,
>+				dev_net(bat_priv->soft_iface), msg, 0,
>+				BATADV_NL_MCGRP_CONFIG, GFP_KERNEL);
>+
>+	return 0;
>+}
>+
>+/**
>+ * batadv_netlink_get_vlan() - Get vlan attributes
>+ * @skb: Netlink message with request data
>+ * @info: receiver information
>+ *
>+ * Return: 0 on success or negative error number in case of failure
>+ */
>+static int batadv_netlink_get_vlan(struct sk_buff *skb, struct genl_info *info)
>+{
>+	struct batadv_softif_vlan *vlan = info->user_ptr[1];
>+	struct batadv_priv *bat_priv = info->user_ptr[0];
>+	struct sk_buff *msg;
>+	int ret;
>+
>+	msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
>+	if (!msg)
>+		return -ENOMEM;
>+
>+	ret = batadv_netlink_vlan_put(msg, bat_priv, vlan, BATADV_CMD_GET_VLAN,
>+				      info->snd_portid, info->snd_seq, 0);

This get/put naming here looks a bit confusing. Better to use "fill" for
example:
	ret = batadv_netlink_vlan_fill(msg, bat_priv, vlan, BATADV_CMD_GET_VLAN,
				       info->snd_portid, info->snd_seq, 0);

>+	if (ret < 0) {

Just "if (!ret)" would do. Same in the rest of the code.


>+		nlmsg_free(msg);
>+		return ret;
>+	}
>+
>+	ret = genlmsg_reply(msg, info);
>+
>+	return ret;
>+}
>+

[...]


  reply	other threads:[~2019-01-21  9:44 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-19 15:56 [B.A.T.M.A.N.] [RFC v4 00/19] batman-adv: netlink restructuring, part 2 Sven Eckelmann
2019-01-19 15:56 ` [B.A.T.M.A.N.] [RFC v4 01/19] batman-adv: Move common genl doit code pre/post hooks Sven Eckelmann
2019-01-19 15:56 ` [B.A.T.M.A.N.] [RFC v4 02/19] batman-adv: Prepare framework for mesh genl config Sven Eckelmann
2019-01-19 15:56 ` [B.A.T.M.A.N.] [RFC v4 03/19] batman-adv: Prepare framework for hardif " Sven Eckelmann
2019-01-19 15:56 ` [B.A.T.M.A.N.] [RFC v4 04/19] batman-adv: Prepare framework for vlan " Sven Eckelmann
2019-01-21  9:44   ` Jiri Pirko [this message]
2019-01-19 15:56 ` [B.A.T.M.A.N.] [RFC v4 05/19] batman-adv: Add aggregated_ogms mesh genl configuration Sven Eckelmann
2019-01-19 15:56 ` [B.A.T.M.A.N.] [RFC v4 06/19] batman-adv: Add ap_isolation mesh/vlan " Sven Eckelmann
2019-01-19 15:56 ` [B.A.T.M.A.N.] [RFC v4 07/19] batman-adv: Add bonding mesh " Sven Eckelmann
2019-01-19 15:56 ` [B.A.T.M.A.N.] [RFC v4 08/19] batman-adv: Add bridge_loop_avoidance " Sven Eckelmann
2019-01-19 15:56 ` [B.A.T.M.A.N.] [RFC v4 09/19] batman-adv: Add distributed_arp_table " Sven Eckelmann
2019-01-19 15:56 ` [B.A.T.M.A.N.] [RFC v4 10/19] batman-adv: Add fragmentation " Sven Eckelmann
2019-01-19 15:56 ` [B.A.T.M.A.N.] [RFC v4 11/19] batman-adv: Add gateway " Sven Eckelmann
2019-01-19 15:56 ` [B.A.T.M.A.N.] [RFC v4 12/19] batman-adv: Add hop_penalty " Sven Eckelmann
2019-01-19 15:56 ` [B.A.T.M.A.N.] [RFC v4 13/19] batman-adv: Add log_level " Sven Eckelmann
2019-01-19 15:56 ` [B.A.T.M.A.N.] [RFC v4 14/19] batman-adv: Add multicast_mode " Sven Eckelmann
2019-01-19 15:56 ` [B.A.T.M.A.N.] [RFC v4 15/19] batman-adv: Add network_coding " Sven Eckelmann
2019-01-19 15:56 ` [B.A.T.M.A.N.] [RFC v4 16/19] batman-adv: Add orig_interval " Sven Eckelmann
2019-01-19 15:56 ` [B.A.T.M.A.N.] [RFC v4 17/19] batman-adv: Add elp_interval hardif " Sven Eckelmann
2019-01-19 15:56 ` [B.A.T.M.A.N.] [RFC v4 18/19] batman-adv: Add throughput_override " Sven Eckelmann
2019-01-19 15:56 ` [B.A.T.M.A.N.] [RFC v4 19/19] batman-adv: Trigger genl notification on sysfs config change Sven Eckelmann
2019-01-21  9:47 ` [B.A.T.M.A.N.] [RFC v4 00/19] batman-adv: netlink restructuring, part 2 Jiri Pirko
2019-01-26 10:47 ` Sven Eckelmann
2019-01-27  8:45   ` Jiri Pirko
2019-02-05 17:04   ` Simon Wunderlich
2019-02-05 19:24   ` Linus Lüssing
2019-02-06 18:20     ` Sven Eckelmann
2019-02-06 19:08       ` Linus Lüssing
2019-02-07 10:02         ` Sven Eckelmann

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=20190121094430.GC2228@nanopsycho \
    --to=jiri@resnulli.us \
    --cc=b.a.t.m.a.n@lists.open-mesh.org \
    --cc=jiri@mellanox.com \
    --cc=netdev@vger.kernel.org \
    --cc=sven@narfation.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).