Commit 09fcde54 authored by David S. Miller's avatar David S. Miller
Browse files

Merge branch 'mptcp-userspace-pm'



Matthieu Baerts says:

====================
mptcp: userspace pm: 'dump addrs' and 'get addr'

This series from Geliang adds two new Netlink commands to the userspace
PM:

- one to dump all addresses of a specific MPTCP connection:
  - feature added in patches 3 to 5
  - test added in patches 7, 8 and 10

- and one to get a specific address for an MPTCP connection:
  - feature added in patches 11 to 13
  - test added in patches 14 and 15

These new Netlink commands can be useful if an MPTCP daemon lost track
of the different connections, e.g. after having been restarted.

The other patches are some clean-ups and small improvements added
while working on the new features.

====================

Signed-off-by: default avatarMatthieu Baerts (NGI0) <matttbe@kernel.org>
parents 86a628be 4cc5cc7c
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -292,13 +292,14 @@ operations:
    -
      name: get-addr
      doc: Get endpoint information
      attribute-set: endpoint
      attribute-set: attr
      dont-validate: [ strict ]
      flags: [ uns-admin-perm ]
      do: &get-addr-attrs
        request:
          attributes:
           - addr
           - token
        reply:
          attributes:
           - addr
+4 −3
Original line number Diff line number Diff line
@@ -32,8 +32,9 @@ const struct nla_policy mptcp_pm_del_addr_nl_policy[MPTCP_PM_ENDPOINT_ADDR + 1]
};

/* MPTCP_PM_CMD_GET_ADDR - do */
const struct nla_policy mptcp_pm_get_addr_nl_policy[MPTCP_PM_ENDPOINT_ADDR + 1] = {
	[MPTCP_PM_ENDPOINT_ADDR] = NLA_POLICY_NESTED(mptcp_pm_address_nl_policy),
const struct nla_policy mptcp_pm_get_addr_nl_policy[MPTCP_PM_ATTR_TOKEN + 1] = {
	[MPTCP_PM_ATTR_ADDR] = NLA_POLICY_NESTED(mptcp_pm_address_nl_policy),
	[MPTCP_PM_ATTR_TOKEN] = { .type = NLA_U32, },
};

/* MPTCP_PM_CMD_FLUSH_ADDRS - do */
@@ -110,7 +111,7 @@ const struct genl_ops mptcp_pm_nl_ops[11] = {
		.doit		= mptcp_pm_nl_get_addr_doit,
		.dumpit		= mptcp_pm_nl_get_addr_dumpit,
		.policy		= mptcp_pm_get_addr_nl_policy,
		.maxattr	= MPTCP_PM_ENDPOINT_ADDR,
		.maxattr	= MPTCP_PM_ATTR_TOKEN,
		.flags		= GENL_UNS_ADMIN_PERM,
	},
	{
+1 −1
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@ extern const struct nla_policy mptcp_pm_add_addr_nl_policy[MPTCP_PM_ENDPOINT_ADD

extern const struct nla_policy mptcp_pm_del_addr_nl_policy[MPTCP_PM_ENDPOINT_ADDR + 1];

extern const struct nla_policy mptcp_pm_get_addr_nl_policy[MPTCP_PM_ENDPOINT_ADDR + 1];
extern const struct nla_policy mptcp_pm_get_addr_nl_policy[MPTCP_PM_ATTR_TOKEN + 1];

extern const struct nla_policy mptcp_pm_flush_addrs_nl_policy[MPTCP_PM_ENDPOINT_ADDR + 1];

+16 −0
Original line number Diff line number Diff line
@@ -441,6 +441,22 @@ int mptcp_pm_get_flags_and_ifindex_by_id(struct mptcp_sock *msk, unsigned int id
	return mptcp_pm_nl_get_flags_and_ifindex_by_id(msk, id, flags, ifindex);
}

int mptcp_pm_get_addr(struct sk_buff *skb, struct genl_info *info)
{
	if (info->attrs[MPTCP_PM_ATTR_TOKEN])
		return mptcp_userspace_pm_get_addr(skb, info);
	return mptcp_pm_nl_get_addr(skb, info);
}

int mptcp_pm_dump_addr(struct sk_buff *msg, struct netlink_callback *cb)
{
	const struct genl_info *info = genl_info_dump(cb);

	if (info->attrs[MPTCP_PM_ATTR_TOKEN])
		return mptcp_userspace_pm_dump_addr(msg, cb);
	return mptcp_pm_nl_dump_addr(msg, cb);
}

int mptcp_pm_set_flags(struct net *net, struct nlattr *token,
		       struct mptcp_pm_addr_entry *loc,
		       struct mptcp_pm_addr_entry *rem, u8 bkup)
+19 −11
Original line number Diff line number Diff line
@@ -18,9 +18,6 @@
#include "protocol.h"
#include "mib.h"

/* forward declaration */
static struct genl_family mptcp_genl_family;

static int pm_nl_pernet_id;

struct mptcp_pm_add_entry {
@@ -1550,7 +1547,7 @@ void mptcp_pm_remove_addrs(struct mptcp_sock *msk, struct list_head *rm_list)
	}
}

void mptcp_pm_remove_addrs_and_subflows(struct mptcp_sock *msk,
static void mptcp_pm_remove_addrs_and_subflows(struct mptcp_sock *msk,
					       struct list_head *rm_list)
{
	struct mptcp_rm_list alist = { .nr = 0 }, slist = { .nr = 0 };
@@ -1636,7 +1633,7 @@ int mptcp_pm_nl_flush_addrs_doit(struct sk_buff *skb, struct genl_info *info)
	return 0;
}

static int mptcp_nl_fill_addr(struct sk_buff *skb,
int mptcp_nl_fill_addr(struct sk_buff *skb,
		       struct mptcp_pm_addr_entry *entry)
{
	struct mptcp_addr_info *addr = &entry->addr;
@@ -1675,7 +1672,7 @@ static int mptcp_nl_fill_addr(struct sk_buff *skb,
	return -EMSGSIZE;
}

int mptcp_pm_nl_get_addr_doit(struct sk_buff *skb, struct genl_info *info)
int mptcp_pm_nl_get_addr(struct sk_buff *skb, struct genl_info *info)
{
	struct nlattr *attr = info->attrs[MPTCP_PM_ENDPOINT_ADDR];
	struct pm_nl_pernet *pernet = genl_info_pm_nl(info);
@@ -1725,7 +1722,12 @@ int mptcp_pm_nl_get_addr_doit(struct sk_buff *skb, struct genl_info *info)
	return ret;
}

int mptcp_pm_nl_get_addr_dumpit(struct sk_buff *msg,
int mptcp_pm_nl_get_addr_doit(struct sk_buff *skb, struct genl_info *info)
{
	return mptcp_pm_get_addr(skb, info);
}

int mptcp_pm_nl_dump_addr(struct sk_buff *msg,
			  struct netlink_callback *cb)
{
	struct net *net = sock_net(msg->sk);
@@ -1768,6 +1770,12 @@ int mptcp_pm_nl_get_addr_dumpit(struct sk_buff *msg,
	return msg->len;
}

int mptcp_pm_nl_get_addr_dumpit(struct sk_buff *msg,
				struct netlink_callback *cb)
{
	return mptcp_pm_dump_addr(msg, cb);
}

static int parse_limit(struct genl_info *info, int id, unsigned int *limit)
{
	struct nlattr *attr = info->attrs[id];
@@ -2281,7 +2289,7 @@ void mptcp_event(enum mptcp_event_type type, const struct mptcp_sock *msk,
	nlmsg_free(skb);
}

static struct genl_family mptcp_genl_family __ro_after_init = {
struct genl_family mptcp_genl_family __ro_after_init = {
	.name		= MPTCP_PM_NAME,
	.version	= MPTCP_PM_VER,
	.netnsok	= true,
Loading