Skip to content

Commit

Permalink
mptcp: allow changing the "backup" bit by endpoint id
Browse files Browse the repository at this point in the history
[ Upstream commit 602837e ]

a non-zero 'id' is sufficient to identify MPTCP endpoints: allow changing
the value of 'backup' bit by simply specifying the endpoint id.

Link: multipath-tcp/mptcp_net-next#158
Signed-off-by: Davide Caratti <[email protected]>
Signed-off-by: Mat Martineau <[email protected]>
Signed-off-by: Jakub Kicinski <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
  • Loading branch information
dcaratti authored and Sasha Levin committed Jan 30, 2022
1 parent 82ff0a9 commit 5ca945e
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions net/mptcp/pm_netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -1711,22 +1711,28 @@ static int mptcp_nl_addr_backup(struct net *net,

static int mptcp_nl_cmd_set_flags(struct sk_buff *skb, struct genl_info *info)
{
struct mptcp_pm_addr_entry addr = { .addr = { .family = AF_UNSPEC }, }, *entry;
struct nlattr *attr = info->attrs[MPTCP_PM_ATTR_ADDR];
struct pm_nl_pernet *pernet = genl_info_pm_nl(info);
struct mptcp_pm_addr_entry addr, *entry;
struct net *net = sock_net(skb->sk);
u8 bkup = 0;
u8 bkup = 0, lookup_by_id = 0;
int ret;

ret = mptcp_pm_parse_addr(attr, info, true, &addr);
ret = mptcp_pm_parse_addr(attr, info, false, &addr);
if (ret < 0)
return ret;

if (addr.flags & MPTCP_PM_ADDR_FLAG_BACKUP)
bkup = 1;
if (addr.addr.family == AF_UNSPEC) {
lookup_by_id = 1;
if (!addr.addr.id)
return -EOPNOTSUPP;
}

list_for_each_entry(entry, &pernet->local_addr_list, list) {
if (addresses_equal(&entry->addr, &addr.addr, true)) {
if ((!lookup_by_id && addresses_equal(&entry->addr, &addr.addr, true)) ||
(lookup_by_id && entry->addr.id == addr.addr.id)) {
mptcp_nl_addr_backup(net, &entry->addr, bkup);

if (bkup)
Expand Down

0 comments on commit 5ca945e

Please sign in to comment.