mptcp netlink event support
Subsystems (2)
Florian Westphal
cover mptcp netlink event support
This series adds netlink event support.
The format is largely identical to the one used by the out-of-tree kernel, with the exception of the genl name.
Out of tree kernel uses "mptcp", while this used the existing "mptcp_pm".
The initial two patches are preparation patches not related to the rest, so they could be applied independently.
The other patches make little sense without the actual netlink patch.
Comments welcome. I'll send a iproute2 patch to help with debugging in a bit.
Florian Westphal (7):
mptcp: pm: add lockdep assertions
mptcp: move pm netlink work into pm_netlink
mptcp: split __mptcp_close_ssk helper
mptcp: pass subflow socket to a few helpers
mptcp: avoid lock_fast usage in accept path
genetlink: add CAP_NET_ADMIN test for multicast bind
mptcp: add netlink event support
include/net/genetlink.h | 1 + include/uapi/linux/mptcp.h | 70 +++++++++ net/mptcp/options.c | 2 +- net/mptcp/pm.c | 26 +++- net/mptcp/pm_netlink.c | 296 ++++++++++++++++++++++++++++++++++++- net/mptcp/protocol.c | 65 ++++---- net/mptcp/protocol.h | 24 +-- net/mptcp/subflow.c | 2 +- net/netlink/genetlink.c | 32 ++++ 9 files changed, 452 insertions(+), 66 deletions(-)
Signature · 1 line
2.26.2
Florian Westphal
PATCH 1/7 mptcp: pm: add lockdep assertions
Add a few assertions to make sure functions are called with the needed locks held.
Two functions gain might_sleep annotations because they contain conditional calls to functions that sleep.
--- net/mptcp/pm.c | 2 ++ net/mptcp/pm_netlink.c | 13 +++++++++++++ net/mptcp/protocol.c | 4 ++++ net/mptcp/protocol.h | 5 +++++ 4 files changed, 24 insertions(+)
net/mptcp/pm.c +2 -0
@@ -20,6 +20,8 @@ int mptcp_pm_announce_addr(struct mptcp_sock *msk,pr_debug ("msk=%p, local_id=%d" , msk, addr->id); +lockdep_assert_held (&msk->pm.lock); +if (add_addr) {pr_warn ("addr_signal error, add_addr=%d" , add_addr);return -EINVAL ;
net/mptcp/pm_netlink.c +13 -0
@@ -138,6 +138,8 @@ select_local_address(const struct pm_nl_pernet *pernet, {struct mptcp_pm_addr_entry *entry, *ret =NULL ; +msk_owned_by_me (msk); +rcu_read_lock ();__mptcp_flush_join_list (msk);list_for_each_entry_rcu (entry, &pernet->local_addr_list, list) {
@@ -195,6 +197,8 @@ lookup_anno_list_by_saddr(struct mptcp_sock *msk, {struct mptcp_pm_add_entry *entry; +lockdep_assert_held (&msk->pm.lock); +list_for_each_entry (entry, &msk->pm.anno_list, list) {if (addresses_equal (&entry->addr, addr, false))return entry;
@@ -270,6 +274,8 @@ static bool mptcp_pm_alloc_anno_list(struct mptcp_sock *msk,struct sock *sk = (struct sock *)msk;struct net *net =sock_net (sk); +lockdep_assert_held (&msk->pm.lock); +if (lookup_anno_list_by_saddr (msk, &entry->addr))return false;
@@ -412,6 +418,9 @@ void mptcp_pm_nl_add_addr_send_ack(struct mptcp_sock *msk) {struct mptcp_subflow_context *subflow; +msk_owned_by_me (msk); +lockdep_assert_held (&msk->pm.lock); +if (!mptcp_pm_should_add_signal_ipv6 (msk) && !mptcp_pm_should_add_signal_port (msk))return ;
@@ -484,6 +493,8 @@ void mptcp_pm_nl_rm_addr_received(struct mptcp_sock *msk)pr_debug ("address rm_id %d" , msk->pm.rm_id); +msk_owned_by_me (msk); +if (!msk->pm.rm_id)return ;
@@ -519,6 +530,8 @@ void mptcp_pm_nl_rm_subflow_received(struct mptcp_sock *msk, u8 rm_id)pr_debug ("subflow rm_id %d" , rm_id); +msk_owned_by_me (msk); +if (!rm_id)return ;
net/mptcp/protocol.c +4 -0
@@ -2170,6 +2170,8 @@ static void __mptcp_close_subflow(struct mptcp_sock *msk) {struct mptcp_subflow_context *subflow, *tmp; +might_sleep (); +list_for_each_entry_safe (subflow, tmp, &msk->conn_list, node) {struct sock *ssk =mptcp_subflow_tcp_sock (subflow);
@@ -2517,6 +2519,8 @@ static void __mptcp_destroy_sock(struct sock *sk)pr_debug ("msk=%p" , msk); +might_sleep (); +/* dispose the ancillatory tcp socket, if any */ if (msk->subflow) {iput (SOCK_INODE (msk->subflow));
net/mptcp/protocol.h +5 -0
@@ -291,6 +291,11 @@ struct mptcp_sock {#define mptcp_for_each_subflow (__msk, __subflow) \ list_for_each_entry(__subflow, &((__msk)->conn_list), node) +static inline void msk_owned_by_me (const struct mptcp_sock *msk) +{ +sock_owned_by_me ((const struct sock *)msk); +} +static inline struct mptcp_sock *mptcp_sk (const struct sock *sk) {return (struct mptcp_sock *)sk;
Signature · 1 line
2.26.2
Mat Martineau
[MPTCP] Re: [PATCH mptcp 1/7] mptcp: pm: add lockdep assertions
Quoted 5 lines · Florian Westphal
Add a few assertions to make sure functions are called with the needed locks held.
Two functions gainmight_sleepannotations because they contain conditional calls to functions that sleep.
Quoted 8 lines
Signed-off-by Florian Westphal <fw(a)strlen.de>---
net/mptcp/pm.c | 2 ++ net/mptcp/pm_netlink.c | 13 +++++++++++++ net/mptcp/protocol.c | 4 ++++ net/mptcp/protocol.h | 5 +++++ 4 files changed, 24 insertions(+)
These annotations look good - I think it would be good to apply this in the export branch now, like you noted in the cover letter.
--
Mat Martineau
Intel
Florian Westphal
PATCH 2/7 mptcp: move pm netlink work into pm_netlink
In reply to Florian Westphalallows to make some functions static and avoids aquire of the pm spinlock in protocol.c.
--- net/mptcp/pm_netlink.c | 45 +++++++++++++++++++++++++++++++++++++----- net/mptcp/protocol.c | 33 +------------------------------ net/mptcp/protocol.h | 6 +----- 3 files changed, 42 insertions(+), 42 deletions(-)
net/mptcp/pm_netlink.c +40 -5
@@ -55,6 +55,8 @@ struct pm_nl_pernet {#define MPTCP_PM_ADDR_MAX 8#define ADD_ADDR_RETRANS_MAX 3 +static void mptcp_pm_nl_add_addr_send_ack (struct mptcp_sock *msk); +static bool addresses_equal (const struct mptcp_addr_info *a,struct mptcp_addr_info *b,bool use_port) {
@@ -369,17 +371,17 @@ static void mptcp_pm_create_subflow_or_signal_addr(struct mptcp_sock *msk) } } -void mptcp_pm_nl_fully_established (struct mptcp_sock *msk) +static void mptcp_pm_nl_fully_established (struct mptcp_sock *msk) {mptcp_pm_create_subflow_or_signal_addr (msk); } -void mptcp_pm_nl_subflow_established (struct mptcp_sock *msk) +static void mptcp_pm_nl_subflow_established (struct mptcp_sock *msk) {mptcp_pm_create_subflow_or_signal_addr (msk); } -void mptcp_pm_nl_add_addr_received (struct mptcp_sock *msk) +static void mptcp_pm_nl_add_addr_received (struct mptcp_sock *msk) {struct sock *sk = (struct sock *)msk;struct mptcp_addr_info remote;
@@ -414,7 +416,7 @@ void mptcp_pm_nl_add_addr_received(struct mptcp_sock *msk)mptcp_pm_nl_add_addr_send_ack (msk); } -void mptcp_pm_nl_add_addr_send_ack (struct mptcp_sock *msk) +static void mptcp_pm_nl_add_addr_send_ack (struct mptcp_sock *msk) {struct mptcp_subflow_context *subflow;
@@ -486,7 +488,7 @@ int mptcp_pm_nl_mp_prio_send_ack(struct mptcp_sock *msk,return -EINVAL ; } -void mptcp_pm_nl_rm_addr_received (struct mptcp_sock *msk) +static void mptcp_pm_nl_rm_addr_received (struct mptcp_sock *msk) {struct mptcp_subflow_context *subflow, *tmp;struct sock *sk = (struct sock *)msk;
@@ -523,6 +525,39 @@ void mptcp_pm_nl_rm_addr_received(struct mptcp_sock *msk) } } +void mptcp_pm_nl_work (struct mptcp_sock *msk) +{ +struct mptcp_pm_data *pm = &msk->pm; + +msk_owned_by_me (msk); + +spin_lock_bh (&msk->pm.lock); + +pr_debug ("msk=%p status=%x" , msk, pm->status); +if (pm->status &BIT (MPTCP_PM_ADD_ADDR_RECEIVED )) { + pm->status &= ~BIT (MPTCP_PM_ADD_ADDR_RECEIVED ); +mptcp_pm_nl_add_addr_received (msk); + } +if (pm->status &BIT (MPTCP_PM_ADD_ADDR_SEND_ACK )) { + pm->status &= ~BIT (MPTCP_PM_ADD_ADDR_SEND_ACK ); +mptcp_pm_nl_add_addr_send_ack (msk); + } +if (pm->status &BIT (MPTCP_PM_RM_ADDR_RECEIVED )) { + pm->status &= ~BIT (MPTCP_PM_RM_ADDR_RECEIVED ); +mptcp_pm_nl_rm_addr_received (msk); + } +if (pm->status &BIT (MPTCP_PM_ESTABLISHED )) { + pm->status &= ~BIT (MPTCP_PM_ESTABLISHED ); +mptcp_pm_nl_fully_established (msk); + } +if (pm->status &BIT (MPTCP_PM_SUBFLOW_ESTABLISHED )) { + pm->status &= ~BIT (MPTCP_PM_SUBFLOW_ESTABLISHED ); +mptcp_pm_nl_subflow_established (msk); + } + +spin_unlock_bh (&msk->pm.lock); +} +void mptcp_pm_nl_rm_subflow_received (struct mptcp_sock *msk,u8 rm_id) {struct mptcp_subflow_context *subflow, *tmp;
net/mptcp/protocol.c +1 -32
@@ -2135,37 +2135,6 @@ static unsigned int mptcp_sync_mss(struct sock *sk, u32 pmtu)return 0 ; } -static void pm_work (struct mptcp_sock *msk) -{ -struct mptcp_pm_data *pm = &msk->pm; - -spin_lock_bh (&msk->pm.lock); - -pr_debug ("msk=%p status=%x" , msk, pm->status); -if (pm->status &BIT (MPTCP_PM_ADD_ADDR_RECEIVED )) { - pm->status &= ~BIT (MPTCP_PM_ADD_ADDR_RECEIVED ); -mptcp_pm_nl_add_addr_received (msk); - } -if (pm->status &BIT (MPTCP_PM_ADD_ADDR_SEND_ACK )) { - pm->status &= ~BIT (MPTCP_PM_ADD_ADDR_SEND_ACK ); -mptcp_pm_nl_add_addr_send_ack (msk); - } -if (pm->status &BIT (MPTCP_PM_RM_ADDR_RECEIVED )) { - pm->status &= ~BIT (MPTCP_PM_RM_ADDR_RECEIVED ); -mptcp_pm_nl_rm_addr_received (msk); - } -if (pm->status &BIT (MPTCP_PM_ESTABLISHED )) { - pm->status &= ~BIT (MPTCP_PM_ESTABLISHED ); -mptcp_pm_nl_fully_established (msk); - } -if (pm->status &BIT (MPTCP_PM_SUBFLOW_ESTABLISHED )) { - pm->status &= ~BIT (MPTCP_PM_SUBFLOW_ESTABLISHED ); -mptcp_pm_nl_subflow_established (msk); - } - -spin_unlock_bh (&msk->pm.lock); -} -static void __mptcp_close_subflow (struct mptcp_sock *msk) {struct mptcp_subflow_context *subflow, *tmp;
@@ -2255,7 +2224,7 @@ static void mptcp_worker(struct work_struct *work)__mptcp_close_subflow (msk);if (msk->pm.status) -pm_work (msk); +mptcp_pm_nl_work (msk);if (test_and_clear_bit (MPTCP_WORK_EOF , &msk->flags))mptcp_check_for_eof (msk);
net/mptcp/protocol.h +1 -5
@@ -644,13 +644,9 @@ int mptcp_pm_get_local_id(struct mptcp_sock *msk, struct sock_common *skc);void __init mptcp_pm_nl_init (void );void mptcp_pm_nl_data_init (struct mptcp_sock *msk); -void mptcp_pm_nl_fully_established (struct mptcp_sock *msk); -void mptcp_pm_nl_subflow_established (struct mptcp_sock *msk); -void mptcp_pm_nl_add_addr_received (struct mptcp_sock *msk); -void mptcp_pm_nl_add_addr_send_ack (struct mptcp_sock *msk); -void mptcp_pm_nl_rm_addr_received (struct mptcp_sock *msk);void mptcp_pm_nl_rm_subflow_received (struct mptcp_sock *msk,u8 rm_id);int mptcp_pm_nl_get_local_id (struct mptcp_sock *msk,struct sock_common *skc); +void mptcp_pm_nl_work (struct mptcp_sock *msk);static inline struct mptcp_ext *mptcp_get_ext (struct sk_buff *skb) {
Signature · 1 line
2.26.2
Mat Martineau
[MPTCP] Re: [PATCH mptcp 2/7] mptcp: move pm netlink work into pm_netlink
Quoted 10 lines · Florian Westphal
allows to make some functions static and avoids aquire of the pm spinlock in
protocol.c.Signed-off-by Florian Westphal <fw(a)strlen.de>---
net/mptcp/pm_netlink.c | 45 +++++++++++++++++++++++++++++++++++++----- net/mptcp/protocol.c | 33 +------------------------------ net/mptcp/protocol.h | 6 +----- 3 files changed, 42 insertions(+), 42 deletions(-)
Also ok with me to apply this to the export branch.
--
Mat Martineau
Intel
Matthieu Baerts
[MPTCP] Re: [PATCH mptcp 2/7] mptcp: move pm netlink work into pm_netlink
Hi Florian, Mat,
Quoted 13 lines · Mat Martineau
Quoted 10 lines · Florian Westphal
allows to make some functions static and avoids aquire of the pm spinlock in
protocol.c.Signed-off-by Florian Westphal <fw(a)strlen.de>---
net/mptcp/pm_netlink.c| 45 +++++++++++++++++++++++++++++++++++++----- net/mptcp/protocol.c | 33 +------------------------------ net/mptcp/protocol.h | 6 +-----3 files changed, 42 insertions(+), 42 deletions(-)
Quoted 1 line
Also ok with me to apply this to the export branch.
Thank you for the patches and the reviews!
Just added the two first patches in our tree with Mat's RvB tag (and I fixed a typo in the commit message reported by codespell):
- 168b68baccfa: mptcp: pm: add lockdep assertions
- 6df8f68967a5: mptcp: move pm netlink work into pm_netlink
- Results: a1d71a555f36..44215ba71300
Tests + export have been queued!
Cheers,
Matt
Signature · 2 lines
Tessares | Belgium | Hybrid Access Solutions www.tessares.net
Florian Westphal
PATCH 3/7 mptcp: split __mptcp_close_ssk helper
In reply to Florian WestphalPrepare for subflow close events:
When mptcp connection is torn down its enough to send the mptcp socket close notification rather than a subflow close event for all of the subflows followed by the mptcp close event.
This splits the helper: mptcp_close_ssk() will emit the close notification, __mptcp_close_ssk will not.
--- net/mptcp/pm_netlink.c | 4 ++-- net/mptcp/protocol.c | 12 +++++++++--- net/mptcp/protocol.h | 4 ++-- 3 files changed, 13 insertions(+), 7 deletions(-)
net/mptcp/pm_netlink.c +2 -2
@@ -512,7 +512,7 @@ static void mptcp_pm_nl_rm_addr_received(struct mptcp_sock *msk)spin_unlock_bh (&msk->pm.lock);mptcp_subflow_shutdown (sk, ssk, how); -__mptcp_close_ssk (sk, ssk, subflow); +mptcp_close_ssk (sk, ssk, subflow);spin_lock_bh (&msk->pm.lock); msk->pm.add_addr_accepted--;
@@ -582,7 +582,7 @@ void mptcp_pm_nl_rm_subflow_received(struct mptcp_sock *msk, u8 rm_id)spin_unlock_bh (&msk->pm.lock);mptcp_subflow_shutdown (sk, ssk, how); -__mptcp_close_ssk (sk, ssk, subflow); +mptcp_close_ssk (sk, ssk, subflow);spin_lock_bh (&msk->pm.lock); msk->pm.local_addr_used--;
net/mptcp/protocol.c +9 -3
@@ -2097,8 +2097,8 @@ static struct sock *mptcp_subflow_get_retrans(const struct mptcp_sock *msk)* so we need to use tcp_close() after detaching them from the mptcp * parent socket. */ -void __mptcp_close_ssk (struct sock *sk,struct sock *ssk, -struct mptcp_subflow_context *subflow) +static void __mptcp_close_ssk (struct sock *sk,struct sock *ssk, +struct mptcp_subflow_context *subflow) {list_del (&subflow->node);
@@ -2130,6 +2130,12 @@ void __mptcp_close_ssk(struct sock *sk, struct sock *ssk,sock_put (ssk); } +void mptcp_close_ssk (struct sock *sk,struct sock *ssk, +struct mptcp_subflow_context *subflow) +{ +__mptcp_close_ssk (sk, ssk, subflow); +} +static unsigned int mptcp_sync_mss (struct sock *sk,u32 pmtu) {return 0 ;
@@ -2147,7 +2153,7 @@ static void __mptcp_close_subflow(struct mptcp_sock *msk)if (inet_sk_state_load (ssk) !=TCP_CLOSE )continue ; -__mptcp_close_ssk ((struct sock *)msk, ssk, subflow); +mptcp_close_ssk ((struct sock *)msk, ssk, subflow); } }
net/mptcp/protocol.h +2 -2
@@ -475,8 +475,8 @@ void mptcp_subflow_fully_established(struct mptcp_subflow_context *subflow,bool mptcp_subflow_data_available (struct sock *sk);void __init mptcp_subflow_init (void );void mptcp_subflow_shutdown (struct sock *sk,struct sock *ssk,int how); -void __mptcp_close_ssk (struct sock *sk,struct sock *ssk, -struct mptcp_subflow_context *subflow); +void mptcp_close_ssk (struct sock *sk,struct sock *ssk, +struct mptcp_subflow_context *subflow);void mptcp_subflow_reset (struct sock *ssk);void mptcp_sock_graft (struct sock *sk,struct socket *parent);
Signature · 1 line
2.26.2
Florian Westphal
PATCH 4/7 mptcp: pass subflow socket to a few helpers
In reply to Florian WestphalPass the first/initial subflow to the existing functions so they can pass this on to the notification handler in the next patch.
--- net/mptcp/options.c | 2 +- net/mptcp/pm.c | 4 ++-- net/mptcp/protocol.c | 4 ++-- net/mptcp/protocol.h | 4 ++-- net/mptcp/subflow.c | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-)
net/mptcp/options.c +1 -1
@@ -866,7 +866,7 @@ static bool check_fully_established(struct mptcp_sock *msk, struct sock *ssk,clear_3rdack_retransmission (ssk);mptcp_pm_subflow_established (msk, subflow); }else { -mptcp_pm_fully_established (msk); +mptcp_pm_fully_established (msk, ssk,GFP_ATOMIC ); }return true;
net/mptcp/pm.c +2 -2
@@ -68,7 +68,7 @@ int mptcp_pm_remove_subflow(struct mptcp_sock *msk, u8 local_id)/* path manager event handlers */ -void mptcp_pm_new_connection (struct mptcp_sock *msk,int server_side) +void mptcp_pm_new_connection (struct mptcp_sock *msk,const struct sock *ssk,int server_side) {struct mptcp_pm_data *pm = &msk->pm;
@@ -116,7 +116,7 @@ static bool mptcp_pm_schedule_work(struct mptcp_sock *msk,return true; } -void mptcp_pm_fully_established (struct mptcp_sock *msk) +void mptcp_pm_fully_established (struct mptcp_sock *msk,const struct sock *ssk,gfp_t gfp) {struct mptcp_pm_data *pm = &msk->pm;
net/mptcp/protocol.c +2 -2
@@ -2993,7 +2993,7 @@ void mptcp_finish_connect(struct sock *ssk)WRITE_ONCE (msk->can_ack,1 );WRITE_ONCE (msk->snd_una, msk->write_seq); -mptcp_pm_new_connection (msk,0 ); +mptcp_pm_new_connection (msk, ssk,0 );mptcp_rcv_space_init (msk, ssk); }
@@ -3237,7 +3237,7 @@ static int mptcp_stream_accept(struct socket *sock, struct socket *newsock,list_add (&subflow->node, &msk->conn_list);sock_hold (msk->first);if (mptcp_is_fully_established (newsk)) -mptcp_pm_fully_established (msk); +mptcp_pm_fully_established (msk, msk->first,GFP_KERNEL );mptcp_copy_inaddrs (newsk, msk->first);mptcp_rcv_space_init (msk, msk->first);
net/mptcp/protocol.h +2 -2
@@ -571,8 +571,8 @@ void mptcp_crypto_hmac_sha(u64 key1, u64 key2, u8 *msg, int len, void *hmac);void __init mptcp_pm_init (void );void mptcp_pm_data_init (struct mptcp_sock *msk); -void mptcp_pm_new_connection (struct mptcp_sock *msk,int server_side); -void mptcp_pm_fully_established (struct mptcp_sock *msk); +void mptcp_pm_new_connection (struct mptcp_sock *msk,const struct sock *ssk,int server_side); +void mptcp_pm_fully_established (struct mptcp_sock *msk,const struct sock *ssk,gfp_t gfp);bool mptcp_pm_allow_new_subflow (struct mptcp_sock *msk);void mptcp_pm_connection_closed (struct mptcp_sock *msk); void mptcp_pm_subflow_established(struct mptcp_sock *msk,
net/mptcp/subflow.c +1 -1
@@ -629,7 +629,7 @@ static struct sock *subflow_syn_recv_sock(const struct sock *sk,* created mptcp socket */ new_msk->sk_destruct = mptcp_sock_destruct; -mptcp_pm_new_connection (mptcp_sk (new_msk),1 ); +mptcp_pm_new_connection (mptcp_sk (new_msk), child,1 );mptcp_token_accept (subflow_req,mptcp_sk (new_msk)); ctx->conn = new_msk; new_msk =NULL ;
Signature · 1 line
2.26.2
Matthieu Baerts
[MPTCP] Re: [PATCH mptcp 4/7] mptcp: pass subflow socket to a few helpers
Hi Florian,
Quoted 2 lines · Florian Westphal
Pass the first/initial subflow to the existing functions so they can pass this on to the notification handler in the next patch.
(tiny detail: I don't know if it is important but we don't do that "in the next patch" but in the last one of the series. But I am sure it is not an issue.)
Cheers,
Matt
Signature · 2 lines
Tessares | Belgium | Hybrid Access Solutions www.tessares.net
Florian Westphal
PATCH 5/7 mptcp: avoid lock_fast usage in accept path
In reply to Florian WestphalOnce event support is added this may need to allocate memory while msk lock is held with softirqs disabled.
Not using lock_fast also allows to do the allocation with GFP_KERNEL.
--- net/mptcp/protocol.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
net/mptcp/protocol.c +2 -3
@@ -3225,9 +3225,8 @@ static int mptcp_stream_accept(struct socket *sock, struct socket *newsock,struct mptcp_sock *msk =mptcp_sk (newsock->sk);struct mptcp_subflow_context *subflow;struct sock *newsk = newsock->sk; -bool slowpath; - slowpath =lock_sock_fast (newsk); +lock_sock (newsk);/* PM/worker can now acquire the first subflow socket * lock without racing with listener queue cleanup,
@@ -3253,7 +3252,7 @@ static int mptcp_stream_accept(struct socket *sock, struct socket *newsock,if (!ssk->sk_socket)mptcp_sock_graft (ssk, newsock); } -unlock_sock_fast (newsk, slowpath); +release_sock (newsk); }if (inet_csk_listen_poll (ssock->sk))
Signature · 1 line
2.26.2
Florian Westphal
PATCH 6/7 genetlink: add CAP_NET_ADMIN test for multicast bind
In reply to Florian Westphalgenetlink sets NL_CFG_F_NONROOT_RECV for its netlink socket so anyone can subscribe to multicast messages.
rtnetlink doesn't allow this unconditionally, rtnetlink_bind() restricts bind requests to CAP_NET_ADMIN for a few groups.
This allows to set GENL_UNS_ADMIN_PERM flag on genl mcast groups to mandate CAP_NET_ADMIN.
This will be used by the upcoming mptcp netlink event facility which exposes the token (mptcp connection identifier) to userspace.
--- include/net/genetlink.h | 1 + net/netlink/genetlink.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+)
include/net/genetlink.h +1 -0
@@ -14,6 +14,7 @@*/ struct genl_multicast_group {char name[GENL_NAMSIZ ]; +u8 flags; };struct genl_ops ;
net/netlink/genetlink.c +32 -0
@@ -1360,11 +1360,43 @@ static struct genl_family genl_ctrl __ro_after_init = { .netnsok = true, }; +static int genl_bind (struct net *net,int group) +{ +const struct genl_family *family; +unsigned int id; +int ret =0 ; + +genl_lock_all (); + +idr_for_each_entry (&genl_fam_idr, family, id) { +const struct genl_multicast_group *grp; +int i; + +if (family->n_mcgrps ==0 ) +continue ; + + i = group - family->mcgrp_offset; +if (i <0 || i >= family->n_mcgrps) +continue ; + + grp = &family->mcgrps[i]; +if ((grp->flags &GENL_UNS_ADMIN_PERM ) && + !ns_capable (net->user_ns,CAP_NET_ADMIN )) + ret = -EPERM ; + +break ; + } + +genl_unlock_all (); +return ret; +} +static int __net_init genl_pernet_init (struct net *net) {struct netlink_kernel_cfg cfg = { .input = genl_rcv, .flags =NL_CFG_F_NONROOT_RECV , + .bind = genl_bind, };/* we'll bump the group number right afterwards */
Signature · 1 line
2.26.2
Florian Westphal
PATCH 7/7 mptcp: add netlink event support
In reply to Florian WestphalAllow userspace (mptcpd) to subscribe to mptcp genl multicast events. This implementation reuses the same event API as the mptcp kernel fork to ease integration of existing tools, e.g. mptcpd.
Supported events include:
1. start and close of an mptcp connection
2. start and close of subflows (joins)
3. announce and withdrawals of addresses
4. subflow priority (backup/non-backup) change.
--- include/uapi/linux/mptcp.h | 70 +++++++++++ net/mptcp/pm.c | 20 +++- net/mptcp/pm_netlink.c | 234 ++++++++++++++++++++++++++++++++++++- net/mptcp/protocol.c | 9 +- net/mptcp/protocol.h | 5 + 5 files changed, 331 insertions(+), 7 deletions(-)
include/uapi/linux/mptcp.h +70 -0
@@ -36,6 +36,7 @@ enum {/* netlink interface */ #define MPTCP_PM_NAME "mptcp_pm"#define MPTCP_PM_CMD_GRP_NAME "mptcp_pm_cmds" +#define MPTCP_PM_EV_GRP_NAME "mptcp_events"#define MPTCP_PM_VER 0x1/*
@@ -104,4 +105,73 @@ struct mptcp_info { __u64 mptcpi_rcv_nxt; }; +/* +* MPTCP_EVENT_CREATED: token, family, saddr4 | saddr6, daddr4 | daddr6, +* sport, dport +* A new MPTCP connection has been created. It is the good time to allocate +* memory and send ADD_ADDR if needed. Depending on the traffic-patterns +* it can take a long time until the MPTCP_EVENT_ESTABLISHED is sent. +* +* MPTCP_EVENT_ESTABLISHED: token, family, saddr4 | saddr6, daddr4 | daddr6, +* sport, dport +* A MPTCP connection is established (can start new subflows). +* +* MPTCP_EVENT_CLOSED: token +* A MPTCP connection has stopped. +* +* MPTCP_EVENT_ANNOUNCED: token, rem_id, family, daddr4 | daddr6 [, dport] +* A new address has been announced by the peer. +* +* MPTCP_EVENT_REMOVED: token, rem_id +* An address has been lost by the peer. +* +* MPTCP_EVENT_SUB_ESTABLISHED: token, family, saddr4 | saddr6, +* daddr4 | daddr6, sport, dport, backup, +* if_idx +* +* MPTCP_EVENT_SUB_CLOSED: token, family, saddr4 | saddr6, daddr4 | daddr6, +* sport, dport, backup, if_idx +* A subflow has been closed. +* +* MPTCP_EVENT_SUB_PRIORITY: token, family, saddr4 | saddr6, daddr4 | daddr6, +* sport, dport, backup, if_idx +*/ +enum mptcp_event_type { +MPTCP_EVENT_UNSPEC =0 , +MPTCP_EVENT_CREATED =1 , +MPTCP_EVENT_ESTABLISHED =2 , +MPTCP_EVENT_CLOSED =3 , + +MPTCP_EVENT_ANNOUNCED =6 , +MPTCP_EVENT_REMOVED =7 , + +MPTCP_EVENT_SUB_ESTABLISHED =10 , +MPTCP_EVENT_SUB_CLOSED =11 , + +MPTCP_EVENT_SUB_PRIORITY =13 , +}; + +enum mptcp_event_attr { +MPTCP_ATTR_UNSPEC =0 , + +MPTCP_ATTR_TOKEN ,/* u32 */ +MPTCP_ATTR_FAMILY ,/* u16 */ +MPTCP_ATTR_LOC_ID ,/* u8 */ +MPTCP_ATTR_REM_ID ,/* u8 */ +MPTCP_ATTR_SADDR4 ,/* be32 */ +MPTCP_ATTR_SADDR6 ,/* struct in6_addr */ +MPTCP_ATTR_DADDR4 ,/* be32 */ +MPTCP_ATTR_DADDR6 ,/* struct in6_addr */ +MPTCP_ATTR_SPORT ,/* be16 */ +MPTCP_ATTR_DPORT ,/* be16 */ +MPTCP_ATTR_BACKUP ,/* u8 */ +MPTCP_ATTR_ERROR ,/* u8 */ +MPTCP_ATTR_FLAGS ,/* u16 */ +MPTCP_ATTR_TIMEOUT ,/* u32 */ +MPTCP_ATTR_IF_IDX ,/* s32 */ + + __MPTCP_ATTR_AFTER_LAST +}; +#define MPTCP_ATTR_MAX (__MPTCP_ATTR_AFTER_LAST - 1) +#endif /* _UAPI_MPTCP_H */
net/mptcp/pm.c +15 -5
@@ -75,6 +75,7 @@ void mptcp_pm_new_connection(struct mptcp_sock *msk, const struct sock *ssk, intpr_debug ("msk=%p, token=%u side=%d" , msk, msk->token, server_side);WRITE_ONCE (pm->server_side, server_side); +mptcp_event (MPTCP_EVENT_CREATED , msk, ssk,GFP_ATOMIC ); }bool mptcp_pm_allow_new_subflow (struct mptcp_sock *msk)
@@ -119,13 +120,10 @@ static bool mptcp_pm_schedule_work(struct mptcp_sock *msk,void mptcp_pm_fully_established (struct mptcp_sock *msk,const struct sock *ssk,gfp_t gfp) {struct mptcp_pm_data *pm = &msk->pm; +bool announce = false;pr_debug ("msk=%p" , msk); -/* try to avoid acquiring the lock below */ -if (!READ_ONCE (pm->work_pending)) -return ; -spin_lock_bh (&pm->lock);/* mptcp_pm_fully_established() can be invoked by multiple
@@ -135,9 +133,15 @@ void mptcp_pm_fully_established(struct mptcp_sock *msk, const struct sock *ssk,if (READ_ONCE (pm->work_pending) && !(msk->pm.status &BIT (MPTCP_PM_ALREADY_ESTABLISHED )))mptcp_pm_schedule_work (msk,MPTCP_PM_ESTABLISHED ); - msk->pm.status |=BIT (MPTCP_PM_ALREADY_ESTABLISHED ); +if ((msk->pm.status &BIT (MPTCP_PM_ALREADY_ESTABLISHED )) ==0 ) + announce = true; + + msk->pm.status |=BIT (MPTCP_PM_ALREADY_ESTABLISHED );spin_unlock_bh (&pm->lock); + +if (announce) +mptcp_event (MPTCP_EVENT_ESTABLISHED , msk, ssk, gfp); }void mptcp_pm_connection_closed (struct mptcp_sock *msk)
@@ -176,6 +180,8 @@ void mptcp_pm_add_addr_received(struct mptcp_sock *msk,pr_debug ("msk=%p remote_id=%d accept=%d" , msk, addr->id,READ_ONCE (pm->accept_addr)); +mptcp_event_addr_announced (msk, addr); +spin_lock_bh (&pm->lock);if (!READ_ONCE (pm->accept_addr)) {
@@ -203,6 +209,8 @@ void mptcp_pm_rm_addr_received(struct mptcp_sock *msk, u8 rm_id)pr_debug ("msk=%p remote_id=%d" , msk, rm_id); +mptcp_event_addr_removed (msk, rm_id); +spin_lock_bh (&pm->lock);mptcp_pm_schedule_work (msk,MPTCP_PM_RM_ADDR_RECEIVED ); pm->rm_id = rm_id;
@@ -215,6 +223,8 @@ void mptcp_pm_mp_prio_received(struct sock *sk, u8 bkup)pr_debug ("subflow->backup=%d, bkup=%d\n" , subflow->backup, bkup); subflow->backup = bkup; + +mptcp_event (MPTCP_EVENT_SUB_PRIORITY ,mptcp_sk (subflow->conn), sk,GFP_ATOMIC ); }/* path manager helpers */
net/mptcp/pm_netlink.c +233 -1
249 lines not on this page · raw message
net/mptcp/protocol.c +8 -1
@@ -2133,6 +2133,7 @@ static void __mptcp_close_ssk(struct sock *sk, struct sock *ssk,void mptcp_close_ssk (struct sock *sk,struct sock *ssk,struct mptcp_subflow_context *subflow) { +mptcp_event (MPTCP_EVENT_SUB_CLOSED ,mptcp_sk (sk), ssk,GFP_KERNEL );__mptcp_close_ssk (sk, ssk, subflow); }
@@ -2570,6 +2571,10 @@ static void mptcp_close(struct sock *sk, long timeout)release_sock (sk);if (do_cancel_work)mptcp_cancel_work (sk); + +if (mptcp_sk (sk)->token) +mptcp_event (MPTCP_EVENT_CLOSED ,mptcp_sk (sk),NULL ,GFP_KERNEL ); +sock_put (sk); }
@@ -3022,7 +3027,7 @@ bool mptcp_finish_join(struct sock *ssk)return false;if (!msk->pm.server_side) -return true; + goto out;if (!mptcp_pm_allow_new_subflow (msk))return false;
@@ -3049,6 +3054,8 @@ bool mptcp_finish_join(struct sock *ssk)if (parent_sock && !ssk->sk_socket)mptcp_sock_graft (ssk, parent_sock); subflow->map_seq =READ_ONCE (msk->ack_seq); +out: +mptcp_event (MPTCP_EVENT_SUB_ESTABLISHED , msk, ssk,GFP_ATOMIC );return true; }
net/mptcp/protocol.h +5 -0
@@ -10,6 +10,7 @@#include <linux/random.h> #include <net/tcp.h> #include <net/inet_connection_sock.h> +#include <uapi/linux/mptcp.h> #define MPTCP_SUPPORTED_VERSION 1
@@ -597,6 +598,10 @@ int mptcp_pm_announce_addr(struct mptcp_sock *msk,int mptcp_pm_remove_addr (struct mptcp_sock *msk,u8 local_id);int mptcp_pm_remove_subflow (struct mptcp_sock *msk,u8 local_id); +void mptcp_event (enum mptcp_event_type type,const struct mptcp_sock *msk,const struct sock *ssk,gfp_t gfp); +void mptcp_event_addr_announced (const struct mptcp_sock *msk,const struct mptcp_addr_info *info); +void mptcp_event_addr_removed (const struct mptcp_sock *msk,u8 id); +static inline bool mptcp_pm_should_add_signal (struct mptcp_sock *msk) {return READ_ONCE (msk->pm.addr_signal) &BIT (MPTCP_ADD_ADDR_SIGNAL );
Signature · 1 line
2.26.2
Matthieu Baerts
[MPTCP] Re: [PATCH mptcp 7/7] mptcp: add netlink event support
Hi Florian,
Quoted 9 lines · Florian Westphal
Allow userspace (mptcpd) to subscribe to mptcp genl multicast events. This implementation reuses the same event API as the mptcp kernel fork to ease integration of existing tools, e.g. mptcpd.
Supported events include:
1. start and close of an mptcp connection
2. start and close of subflows (joins)
3. announce and withdrawals of addresses
4. subflow priority (backup/non-backup) change.
Thank you for looking at that, that's really nice! :)
The previous patches look really good to me but I would not mind a second look for the previous patches modifying how the locks are used:
I'm not sure I have a good global view to give a proper review on these ones.
My comments for this patch are below if you don't mind looking:
Quoted 29 lines
include/uapi/linux/mptcp.h +14
-0@@ -36,6 +36,7 @@ enum {/* netlink interface */ #define MPTCP_PM_NAME "mptcp_pm"#define MPTCP_PM_CMD_GRP_NAME "mptcp_pm_cmds" +#define MPTCP_PM_EV_GRP_NAME "mptcp_events"#define MPTCP_PM_VER 0x1/* @@ -104,4 +105,73 @@ struct mptcp_info {__u64 mptcpi_rcv_nxt; }; +/* +* MPTCP_EVENT_CREATED: token, family, saddr4 | saddr6, daddr4 | daddr6, +* sport, dport +* A new MPTCP connection has been created. It is the good time to allocate +* memory and send ADD_ADDR if needed. Depending on the traffic-patterns +* it can take a long time until the MPTCP_EVENT_ESTABLISHED is sent. +* +* MPTCP_EVENT_ESTABLISHED: token, family, saddr4 | saddr6, daddr4 | daddr6, +* sport, dport +* A MPTCP connection is established (can start new subflows). +* +* MPTCP_EVENT_CLOSED: token +* A MPTCP connection has stopped.
include/uapi/linux/mptcp.h struct mptcp_info { · line 130
Quoted 10 lines
include/uapi/linux/mptcp.h +10
-0+* +* MPTCP_EVENT_ANNOUNCED: token, rem_id, family, daddr4 | daddr6 [, dport] +* A new address has been announced by the peer. +* +* MPTCP_EVENT_REMOVED: token, rem_id +* An address has been lost by the peer. +* +* MPTCP_EVENT_SUB_ESTABLISHED: token, family, saddr4 | saddr6, +* daddr4 | daddr6, sport, dport, backup, +* if_idx
Even if it is quite obvious, should we add a comment for this one like for the others, e.g.
A new subflow has been established.
(at least to explain that "sub" stands for "subflow" :) )
include/uapi/linux/mptcp.h struct mptcp_info { · line 134
Quoted 4 lines
include/uapi/linux/mptcp.h +4
-0+* +* MPTCP_EVENT_SUB_CLOSED: token, family, saddr4 | saddr6, daddr4 | daddr6, +* sport, dport, backup, if_idx +* A subflow has been closed.
I noticed that the error (copy of sk_err) is not in the arguments. Is it simply because we don't need them in the first version or because there is a technical issue?
A PM might want to know why a subflow has been closed: was it closed by a RST, timeout, etc.?
No issue for me to add it later (if it is possible) ;-)
include/uapi/linux/mptcp.h struct mptcp_info { · line 138
Quoted 4 lines
include/uapi/linux/mptcp.h +4
-0+* +* MPTCP_EVENT_SUB_PRIORITY: token, family, saddr4 | saddr6, daddr4 | daddr6, +* sport, dport, backup, if_idx +*/
May we add a short description here too?
The priority of a subflow has changed.
(...)
Quoted 4 lines
net/mptcp/pm_netlink.c +0
-0
(...)
Quoted 1 line
+static int
mptcp_event_sub_established(struct sk_buff *skb, const struct mptcp_sock *msk, const struct sock *ssk)
(tiny detail: is it OK to have such long line? Same for the functions below. Just to avoid checkpatch warnings but it is maybe not catched by checkpatch?)
(...)
net/mptcp/pm_netlink.c static int mptcp_nl_cmd_set_flags(struct sk_buff *skb, struct genl_info *info) · line 1361
Quoted 3 lines
net/mptcp/pm_netlink.c +3
-0+static int mptcp_event_sub_closed (struct sk_buff *skb,const struct mptcp_sock *msk,const struct sock *ssk) +{ +if (mptcp_event_sub_established (skb, msk, ssk))
That looks strange to call mptcp_event_sub_established() in mptcp_event_sub_closed() but I understand we want to pack the same info :)
(...)
net/mptcp/pm_netlink.c static int mptcp_nl_cmd_set_flags(struct sk_buff *skb, struct genl_info *info) · line 1380
Quoted 4 lines
net/mptcp/pm_netlink.c +4
-0+void mptcp_event_addr_removed (const struct mptcp_sock *msk,uint8_t id) +{ +struct net *net =sock_net ((const struct sock *)msk); +struct nlmsghdr *nlh;
(detail: the indentation is not correct)
(...)
net/mptcp/pm_netlink.c
Quoted 1 line
net/mptcp/pm_netlink.c +1
-0+return mptcp_nl_mcast_send (net, skb,GFP_ATOMIC );
Just out of curiosity, is it always OK to have a "return f()" here while the current function returns a "void"? I am sure it is OK because the called function also returns "void" but no issues with some compilers (and some options) nor static analytic tools?
(no need to change of course, just I would not have thought about writing it like that)
net/mptcp/pm_netlink.c static int mptcp_nl_cmd_set_flags(struct sk_buff *skb, struct genl_info *info) · line 1410
Quoted 9 lines
net/mptcp/pm_netlink.c +9
-0+ +nla_put_failure: +kfree_skb (skb); +} + +void mptcp_event_addr_announced (const struct mptcp_sock *msk,const struct mptcp_addr_info *info) +{ +struct net *net =sock_net ((const struct sock *)msk); +struct nlmsghdr *nlh;
(detail: the indentation is not correct)
Quoted 7 lines
net/mptcp/pm_netlink.c +7
-0+struct sk_buff *skb; + +if (!genl_has_listeners (&mptcp_genl_family, net,MPTCP_PM_EV_GRP_OFFSET )) +return ; + + skb =nlmsg_new (NLMSG_DEFAULT_SIZE ,GFP_ATOMIC ); +if (!skb)
net/mptcp/pm_netlink.c static int mptcp_nl_cmd_set_flags(struct sk_buff *skb, struct genl_info *info) · line 1427
Quoted 10 lines
net/mptcp/pm_netlink.c +10
-0+return ; + + nlh =genlmsg_put (skb,0 ,0 , &mptcp_genl_family,0 ,MPTCP_EVENT_ANNOUNCED ); +if (!nlh) + goto nla_put_failure; + +if (nla_put_u32 (skb,MPTCP_ATTR_TOKEN , msk->token)) + goto nla_put_failure; + +if (nla_put_u32 (skb,MPTCP_ATTR_REM_ID , info->id))
I think it's a u8 for rem ID.
Same above in mptcp_event_addr_removed()
net/mptcp/pm_netlink.c static int mptcp_nl_cmd_set_flags(struct sk_buff *skb, struct genl_info *info) · line 1435
Quoted 8 lines
net/mptcp/pm_netlink.c +8
-0+ goto nla_put_failure; + +if (nla_put_be16 (skb,MPTCP_ATTR_DPORT , info->port)) + goto nla_put_failure; + +switch (info->family) { +case AF_INET : +if (nla_put_in_addr (skb,MPTCP_ATTR_DADDR4 , info->addr.s_addr))
(I should not review that late, I blocked here a few seconds thinking you were using the "source" addr for DADDR :) )
Quoted 14 lines
net/mptcp/pm_netlink.c +14
-0+ goto nla_put_failure; +break ; +#if IS_ENABLED (CONFIG_MPTCP_IPV6 ) +case AF_INET6 : +if (nla_put_in6_addr (skb,MPTCP_ATTR_DADDR6 , &info->addr6)) + goto nla_put_failure; +break ; +#endif +default : +WARN_ON_ONCE (1 ); + goto nla_put_failure; + } + +genlmsg_end (skb, nlh);
net/mptcp/pm_netlink.c static int mptcp_nl_cmd_set_flags(struct sk_buff *skb, struct genl_info *info) · line 1459
Quoted 10 lines
net/mptcp/pm_netlink.c +10
-0+return mptcp_nl_mcast_send (net, skb,GFP_ATOMIC ); + +nla_put_failure: +kfree_skb (skb); +} + +void mptcp_event (enum mptcp_event_type type,const struct mptcp_sock *msk,const struct sock *ssk,gfp_t gfp) +{ +struct net *net =sock_net ((const struct sock *)msk); +struct nlmsghdr *nlh;
(detail: the indentation is not correct)
Quoted 7 lines
net/mptcp/pm_netlink.c +7
-0+struct sk_buff *skb; + +if (!genl_has_listeners (&mptcp_genl_family, net,MPTCP_PM_EV_GRP_OFFSET )) +return ; + + skb =nlmsg_new (NLMSG_DEFAULT_SIZE , gfp); +if (!skb)
net/mptcp/pm_netlink.c static int mptcp_nl_cmd_set_flags(struct sk_buff *skb, struct genl_info *info) · line 1476
Quoted 10 lines
net/mptcp/pm_netlink.c +10
-0+return ; + + nlh =genlmsg_put (skb,0 ,0 , &mptcp_genl_family,0 , type); +if (!nlh) + goto nla_put_failure; + +switch (type) { +case MPTCP_EVENT_UNSPEC : +WARN_ON_ONCE (1 ); +break ;
Probably useless but should we move this to the end and add "default"?
Quoted 14 lines
net/mptcp/pm_netlink.c +14
-0+case MPTCP_EVENT_CREATED : +case MPTCP_EVENT_ESTABLISHED : +if (mptcp_event_created (skb, msk, ssk) <0 ) + goto nla_put_failure; +break ; +case MPTCP_EVENT_CLOSED : +if (nla_put_u32 (skb,MPTCP_ATTR_TOKEN , msk->token) <0 ) + goto nla_put_failure; +break ; +case MPTCP_EVENT_ANNOUNCED : +case MPTCP_EVENT_REMOVED : +/* call mptcp_event_addr_announced()/removed instead */ +WARN_ON_ONCE (1 ); +break ;
net/mptcp/pm_netlink.c static int mptcp_nl_cmd_set_flags(struct sk_buff *skb, struct genl_info *info) · line 1500
Quoted 10 lines
net/mptcp/pm_netlink.c +10
-0+case MPTCP_EVENT_SUB_ESTABLISHED : +case MPTCP_EVENT_SUB_PRIORITY : +if (mptcp_event_sub_established (skb, msk, ssk) <0 ) + goto nla_put_failure; +break ; +case MPTCP_EVENT_SUB_CLOSED : +if (mptcp_event_sub_closed (skb, msk, ssk) <0 ) + goto nla_put_failure; +break ; + }
(...)
Cheers,
Matt
Signature · 2 lines
Tessares | Belgium | Hybrid Access Solutions www.tessares.net
Florian Westphal
[MPTCP] Re: [PATCH mptcp 7/7] mptcp: add netlink event support
Quoted 23 lines · Matthieu Baerts
Quoted 14 lines
+ *
MPTCP_EVENT_CREATED: token, family, saddr4 | saddr6, daddr4 | daddr6,
+ * sport, dport+ * A new MPTCP connection has been created. It is the good time to allocate + * memory and send ADD_ADDR if needed. Depending on the traffic-patterns + * it can take a long time until the MPTCP_EVENT_ESTABLISHED is sent.+ *
+ *MPTCP_EVENT_ESTABLISHED: token, family, saddr4 | saddr6, daddr4 | daddr6,
+ * sport, dport
+ * A MPTCP connection is established (can start new subflows).
+ *
+ *MPTCP_EVENT_CLOSED: token
+ * A MPTCP connection has stopped.
+ *
+ *MPTCP_EVENT_ANNOUNCED: token,rem_id, family, daddr4 | daddr6 [, dport]Quoted 8 lines
+ * A new address has been announced by the peer.
+ *
+ *MPTCP_EVENT_REMOVED: token,rem_id
+ * An address has been lost by the peer.
+ *
+ *MPTCP_EVENT_SUB_ESTABLISHED: token, family, saddr4 | saddr6,
+ * daddr4 | daddr6, sport, dport, backup,
+ *if_idx
Quoted 6 lines
Even if it is quite obvious, should we add a comment for this one like for the others, e.g.
A new subflow has been established.
(at least to explain that "sub" stands for "subflow" :) )
Done.
Quoted 8 lines
Quoted 4 lines
+ *
+ *MPTCP_EVENT_SUB_CLOSED: token, family, saddr4 | saddr6, daddr4 | daddr6,
+ * sport, dport, backup,if_idx
+ * A subflow has been closed.I noticed that the error (copy of
sk_err) is not in the arguments. Is it simply because we don't need them in the first version or because there is a technical issue?
No, i've added it now for v2. It exports ssk->sk_err in the subflow announcements.
Quoted 7 lines
Quoted 3 lines
+ *
MPTCP_EVENT_SUB_PRIORITY: token, family, saddr4 | saddr6, daddr4 | daddr6,
+ * sport, dport, backup,if_idx
+ */May we add a short description here too?
The priority of a subflow has changed.
Sure, I took the one from mptc kernel.
Quoted 5 lines
Quoted 1 line
+static int
mptcp_event_sub_established(struct sk_buff *skb, const struct mptcp_sock *msk, const struct sock *ssk)(tiny detail: is it OK to have such long line? Same for the functions below. Just to avoid checkpatch warnings but it is maybe not catched by checkpatch?)
No, checkpatch barfs here. I've added linebreaks everywhere.
Quoted 6 lines
net/mptcp/pm_netlink.c static int mptcp_nl_cmd_set_flags(struct sk_buff *skb, struct genl_info *info) · line 1361
Quoted 3 lines
net/mptcp/pm_netlink.c +3
-0+static int mptcp_event_sub_closed (struct sk_buff *skb,const struct mptcp_sock *msk,const struct sock *ssk) +{ +if (mptcp_event_sub_established (skb, msk, ssk))That looks strange to call
mptcp_event_sub_established()inmptcp_event_sub_closed()but I understand we want to pack the same info :)
I've renamed the function for next iteration.
Quoted 4 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ struct net *net = sock_net((const struct sock *)msk); + struct nlmsghdr *nlh;(detail: the indentation is not correct)
Right, I've fixed this up.
Quoted 6 lines
Review
Quoted 1 line
(quoted diff) +1
-0+ return mptcp_nl_mcast_send(net, skb, GFP_ATOMIC);Just out of curiosity, is it always OK to have a "return
f()" here while the current function returns a "void"? I am sure it is OK because the called function also returns "void" but no issues with some compilers (and some options) nor static analytic tools?
Its ok, but actually comes from an older iteration where return type was 'int'. But since there is no way to deal with a netlink error in a sensible way here i later changed it to void.
I've altered this to the more commonfoo();
return;
Quoted 4 lines
net/mptcp/pm_netlink.c static int mptcp_nl_cmd_set_flags(struct sk_buff *skb, struct genl_info *info) · line 1427
Quoted 1 line
net/mptcp/pm_netlink.c +1
-0+if (nla_put_u32 (skb,MPTCP_ATTR_REM_ID , info->id))I think it's a u8 for rem ID.
Same above inmptcp_event_addr_removed()
Indeed, fixed it up.
Quoted 9 lines
net/mptcp/pm_netlink.c static int mptcp_nl_cmd_set_flags(struct sk_buff *skb, struct genl_info *info) · line 1435
Quoted 6 lines
net/mptcp/pm_netlink.c +6
-0+if (nla_put_be16 (skb,MPTCP_ATTR_DPORT , info->port)) + goto nla_put_failure; + +switch (info->family) { +case AF_INET : +if (nla_put_in_addr (skb,MPTCP_ATTR_DADDR4 , info->addr.s_addr))(I should not review that late, I blocked here a few seconds thinking you were using the "source" addr for DADDR :) )
Right, it would be better to use __be32 instead of struct inaddr but that would result in more (useless) code churn so I left that as-is.
Quoted 5 lines
net/mptcp/pm_netlink.c static int mptcp_nl_cmd_set_flags(struct sk_buff *skb, struct genl_info *info) · line 1476
Quoted 3 lines
net/mptcp/pm_netlink.c +3
-0+case MPTCP_EVENT_UNSPEC : +WARN_ON_ONCE (1 ); +break ;Probably useless but should we move this to the end and add "default"?
gcc emits a warning if you add a new name to an enum and a switch statement doesn't handle that.
This is why there is no default branch but all the other 'should not happen' values are listed verbatim with a warn-on.
Matthieu Baerts
[MPTCP] Re: [PATCH mptcp 7/7] mptcp: add netlink event support
Hi Florian,
Thank you for your reply and explanations!
Sounds good to me!
Quoted 11 lines · Florian Westphal
Quoted 7 lines · Matthieu Baerts
Quoted 3 lines
+ *
MPTCP_EVENT_SUB_CLOSED: token, family, saddr4 | saddr6, daddr4 | daddr6,
+ * sport, dport, backup,if_idx
+ * A subflow has been closed.I noticed that the error (copy of
sk_err) is not in the arguments. Is it simply because we don't need them in the first version or because there is a technical issue?No, i've added it now for v2. It exports
ssk->sk_errin the subflow announcements.
Great, thanks!
Quoted 10 lines
Quoted 9 lines
net/mptcp/pm_netlink.c static int mptcp_nl_cmd_set_flags(struct sk_buff *skb, struct genl_info *info) · line 1435
Quoted 6 lines
net/mptcp/pm_netlink.c +6
-0+if (nla_put_be16 (skb,MPTCP_ATTR_DPORT , info->port)) + goto nla_put_failure; + +switch (info->family) { +case AF_INET : +if (nla_put_in_addr (skb,MPTCP_ATTR_DADDR4 , info->addr.s_addr))(I should not review that late, I blocked here a few seconds thinking you were using the "source" addr for DADDR :) )
Quoted 2 lines
Right, it would be better to use
__be32instead of struct inaddr but that would result in more (useless) code churn so I left that as-is.
All good, this code is good like that :)
(I only blocked yesterday because we hadd "DADDR" followed by s_addr :) )
Quoted 11 lines
Quoted 5 lines
net/mptcp/pm_netlink.c static int mptcp_nl_cmd_set_flags(struct sk_buff *skb, struct genl_info *info) · line 1476
Quoted 3 lines
net/mptcp/pm_netlink.c +3
-0+case MPTCP_EVENT_UNSPEC : +WARN_ON_ONCE (1 ); +break ;Probably useless but should we move this to the end and add "default"?
gcc emits a warning if you add a new name to an enum and a switch statement doesn't handle that.
This is why there is no default branch but all the other 'should not happen' values are listed verbatim with a warn-on.
That's right, I forgot about that!
Cheers,
Matt
Signature · 2 lines
Tessares | Belgium | Hybrid Access Solutions www.tessares.net
Mat Martineau
[MPTCP] Re: [PATCH mptcp 7/7] mptcp: add netlink event support
In reply to Florian WestphalQuoted 11 lines · Florian Westphal
Allow userspace (mptcpd) to subscribe to mptcp genl multicast events. This implementation reuses the same event API as the mptcp kernel fork to ease integration of existing tools, e.g. mptcpd.
Supported events include:
1. start and close of an mptcp connection
2. start and close of subflows (joins)
3. announce and withdrawals of addresses
4. subflow priority (backup/non-backup) change.Signed-off-by Florian Westphal <fw(a)strlen.de>
Thanks for the patch series, Florian. I have a few minor comments below, and will work with Ossama to get mptcpd listening to the events on the upstream kernel and really test things out.
Quoted 13 lines
---
include/uapi/linux/mptcp.h | 70 +++++++++++ net/mptcp/pm.c | 20 +++- net/mptcp/pm_netlink.c | 234 ++++++++++++++++++++++++++++++++++++- net/mptcp/protocol.c | 9 +- net/mptcp/protocol.h | 5 + 5 files changed, 331 insertions(+), 7 deletions(-)include/uapi/linux/mptcp.h +0
-0
include/uapi/linux/mptcp.h enum { · line 39
Quoted 4 lines
include/uapi/linux/mptcp.h +1
-0@@ -36,6 +36,7 @@ enum {/* netlink interface */ #define MPTCP_PM_NAME "mptcp_pm"#define MPTCP_PM_CMD_GRP_NAME "mptcp_pm_cmds" +#define MPTCP_PM_EV_GRP_NAME "mptcp_events"
Suggest "mptcp_pm_events" instead.
Quoted 280 lines
include/uapi/linux/mptcp.h +69
-0#define MPTCP_PM_VER 0x1/* @@ -104,4 +105,73 @@ struct mptcp_info { __u64 mptcpi_rcv_nxt; }; +/* +* MPTCP_EVENT_CREATED: token, family, saddr4 | saddr6, daddr4 | daddr6, +* sport, dport +* A new MPTCP connection has been created. It is the good time to allocate +* memory and send ADD_ADDR if needed. Depending on the traffic-patterns +* it can take a long time until the MPTCP_EVENT_ESTABLISHED is sent. +* +* MPTCP_EVENT_ESTABLISHED: token, family, saddr4 | saddr6, daddr4 | daddr6, +* sport, dport +* A MPTCP connection is established (can start new subflows). +* +* MPTCP_EVENT_CLOSED: token +* A MPTCP connection has stopped. +* +* MPTCP_EVENT_ANNOUNCED: token, rem_id, family, daddr4 | daddr6 [, dport] +* A new address has been announced by the peer. +* +* MPTCP_EVENT_REMOVED: token, rem_id +* An address has been lost by the peer. +* +* MPTCP_EVENT_SUB_ESTABLISHED: token, family, saddr4 | saddr6, +* daddr4 | daddr6, sport, dport, backup, +* if_idx +* +* MPTCP_EVENT_SUB_CLOSED: token, family, saddr4 | saddr6, daddr4 | daddr6, +* sport, dport, backup, if_idx +* A subflow has been closed. +* +* MPTCP_EVENT_SUB_PRIORITY: token, family, saddr4 | saddr6, daddr4 | daddr6, +* sport, dport, backup, if_idx +*/ +enum mptcp_event_type { +MPTCP_EVENT_UNSPEC =0 , +MPTCP_EVENT_CREATED =1 , +MPTCP_EVENT_ESTABLISHED =2 , +MPTCP_EVENT_CLOSED =3 , + +MPTCP_EVENT_ANNOUNCED =6 , +MPTCP_EVENT_REMOVED =7 , + +MPTCP_EVENT_SUB_ESTABLISHED =10 , +MPTCP_EVENT_SUB_CLOSED =11 , + +MPTCP_EVENT_SUB_PRIORITY =13 , +}; + +enum mptcp_event_attr { +MPTCP_ATTR_UNSPEC =0 , + +MPTCP_ATTR_TOKEN ,/* u32 */ +MPTCP_ATTR_FAMILY ,/* u16 */ +MPTCP_ATTR_LOC_ID ,/* u8 */ +MPTCP_ATTR_REM_ID ,/* u8 */ +MPTCP_ATTR_SADDR4 ,/* be32 */ +MPTCP_ATTR_SADDR6 ,/* struct in6_addr */ +MPTCP_ATTR_DADDR4 ,/* be32 */ +MPTCP_ATTR_DADDR6 ,/* struct in6_addr */ +MPTCP_ATTR_SPORT ,/* be16 */ +MPTCP_ATTR_DPORT ,/* be16 */ +MPTCP_ATTR_BACKUP ,/* u8 */ +MPTCP_ATTR_ERROR ,/* u8 */ +MPTCP_ATTR_FLAGS ,/* u16 */ +MPTCP_ATTR_TIMEOUT ,/* u32 */ +MPTCP_ATTR_IF_IDX ,/* s32 */ + + __MPTCP_ATTR_AFTER_LAST +}; +#define MPTCP_ATTR_MAX (__MPTCP_ATTR_AFTER_LAST - 1) +#endif /* _UAPI_MPTCP_H */ net/mptcp/pm.c +15
-5@@ -75,6 +75,7 @@ void mptcp_pm_new_connection(struct mptcp_sock *msk, const struct sock *ssk, intpr_debug ("msk=%p, token=%u side=%d" , msk, msk->token, server_side);WRITE_ONCE (pm->server_side, server_side); +mptcp_event (MPTCP_EVENT_CREATED , msk, ssk,GFP_ATOMIC ); }bool mptcp_pm_allow_new_subflow (struct mptcp_sock *msk)@@ -119,13 +120,10 @@ static bool mptcp_pm_schedule_work(struct mptcp_sock *msk,void mptcp_pm_fully_established (struct mptcp_sock *msk,const struct sock *ssk,gfp_t gfp) {struct mptcp_pm_data *pm = &msk->pm; +bool announce = false;pr_debug ("msk=%p" , msk); -/* try to avoid acquiring the lock below */ -if (!READ_ONCE (pm->work_pending)) -return ; -spin_lock_bh (&pm->lock);/* mptcp_pm_fully_established() can be invoked by multiple @@ -135,9 +133,15 @@ void mptcp_pm_fully_established(struct mptcp_sock *msk, const struct sock *ssk,if (READ_ONCE (pm->work_pending) && !(msk->pm.status &BIT (MPTCP_PM_ALREADY_ESTABLISHED )))mptcp_pm_schedule_work (msk,MPTCP_PM_ESTABLISHED ); - msk->pm.status |=BIT (MPTCP_PM_ALREADY_ESTABLISHED ); +if ((msk->pm.status &BIT (MPTCP_PM_ALREADY_ESTABLISHED )) ==0 ) + announce = true; + + msk->pm.status |=BIT (MPTCP_PM_ALREADY_ESTABLISHED );spin_unlock_bh (&pm->lock); + +if (announce) +mptcp_event (MPTCP_EVENT_ESTABLISHED , msk, ssk, gfp); }void mptcp_pm_connection_closed (struct mptcp_sock *msk)@@ -176,6 +180,8 @@ void mptcp_pm_add_addr_received(struct mptcp_sock *msk,pr_debug ("msk=%p remote_id=%d accept=%d" , msk, addr->id,READ_ONCE (pm->accept_addr)); +mptcp_event_addr_announced (msk, addr); +spin_lock_bh (&pm->lock);if (!READ_ONCE (pm->accept_addr)) {@@ -203,6 +209,8 @@ void mptcp_pm_rm_addr_received(struct mptcp_sock *msk, u8 rm_id)pr_debug ("msk=%p remote_id=%d" , msk, rm_id); +mptcp_event_addr_removed (msk, rm_id); +spin_lock_bh (&pm->lock);mptcp_pm_schedule_work (msk,MPTCP_PM_RM_ADDR_RECEIVED ); pm->rm_id = rm_id;@@ -215,6 +223,8 @@ void mptcp_pm_mp_prio_received(struct sock *sk, u8 bkup)pr_debug ("subflow->backup=%d, bkup=%d\n" , subflow->backup, bkup); subflow->backup = bkup; + +mptcp_event (MPTCP_EVENT_SUB_PRIORITY ,mptcp_sk (subflow->conn), sk,GFP_ATOMIC ); }/* path manager helpers */ net/mptcp/pm_netlink.c +5
-1@@ -731,10 +731,14 @@ void mptcp_pm_nl_data_init(struct mptcp_sock *msk)WRITE_ONCE (pm->accept_subflow, subflows); } -#define MPTCP_PM_CMD_GRP_OFFSET 0 +#define MPTCP_PM_CMD_GRP_OFFSET 0 +#define MPTCP_PM_EV_GRP_OFFSET 1static const struct genl_multicast_group mptcp_pm_mcgrps[] = { [MPTCP_PM_CMD_GRP_OFFSET ] = { .name =MPTCP_PM_CMD_GRP_NAME , }, + [MPTCP_PM_EV_GRP_OFFSET ] = { .name =MPTCP_PM_EV_GRP_NAME , + .flags =GENL_UNS_ADMIN_PERM , + }, };static const struct
nla_policynet/mptcp/pm_netlink.c +108
-0@@ -1274,6 +1278,234 @@ static int mptcp_nl_cmd_set_flags(struct sk_buff *skb, struct genl_info *info)return 0 ; } +static void mptcp_nl_mcast_send (struct net *net,struct sk_buff *nlskb,gfp_t gfp) +{ +genlmsg_multicast_netns (&mptcp_genl_family, net, + nlskb,0 ,MPTCP_PM_EV_GRP_OFFSET , gfp); +} + +static int mptcp_event_add_subflow (struct sk_buff *skb,const struct sock *ssk) +{ +const struct inet_sock *issk =inet_sk (ssk); +const struct mptcp_subflow_context *sf; + +if (nla_put_u16 (skb,MPTCP_ATTR_FAMILY , ssk->sk_family)) +return -EMSGSIZE ; + +switch (ssk->sk_family) { +case AF_INET : +if (nla_put_in_addr (skb,MPTCP_ATTR_SADDR4 , issk->inet_saddr)) +return -EMSGSIZE ; +if (nla_put_in_addr (skb,MPTCP_ATTR_DADDR4 , issk->inet_daddr)) +return -EMSGSIZE ; +break ; +#if IS_ENABLED (CONFIG_MPTCP_IPV6 ) +case AF_INET6 : { +const struct ipv6_pinfo *np =inet6_sk (ssk); + +if (nla_put_in6_addr (skb,MPTCP_ATTR_SADDR6 , &np->saddr)) +return -EMSGSIZE ; +if (nla_put_in6_addr (skb,MPTCP_ATTR_DADDR6 , &ssk->sk_v6_daddr)) +return -EMSGSIZE ; +break ; + } +#endif +default : +WARN_ON_ONCE (1 ); +return -EMSGSIZE ; + } + +if (nla_put_be16 (skb,MPTCP_ATTR_SPORT , issk->inet_sport)) +return -EMSGSIZE ; +if (nla_put_be16 (skb,MPTCP_ATTR_DPORT , issk->inet_dport)) +return -EMSGSIZE ; + + sf =mptcp_subflow_ctx (ssk); +if (WARN_ON_ONCE (!sf)) +return -EINVAL ; + +if (nla_put_u8 (skb,MPTCP_ATTR_LOC_ID , sf->local_id)) +return -EMSGSIZE ; + +if (nla_put_u8 (skb,MPTCP_ATTR_REM_ID , sf->remote_id)) +return -EMSGSIZE ; + +return 0 ; +} + +static int mptcp_event_sub_established (struct sk_buff *skb,const struct mptcp_sock *msk,const struct sock *ssk) +{ +const struct mptcp_subflow_context *sf; + +if (nla_put_u32 (skb,MPTCP_ATTR_TOKEN , msk->token)) +return -EMSGSIZE ; + +if (mptcp_event_add_subflow (skb, ssk)) +return -EMSGSIZE ; + + sf =mptcp_subflow_ctx (ssk); +if (WARN_ON_ONCE (!sf)) +return -EINVAL ; + +if (nla_put_u8 (skb,MPTCP_ATTR_BACKUP , sf->backup)) +return -EMSGSIZE ; + +if (ssk->sk_bound_dev_if &&nla_put_s32 (skb,MPTCP_ATTR_IF_IDX , ssk->sk_bound_dev_if)) +return -EMSGSIZE ; + +return 0 ; +} + +static int mptcp_event_sub_closed (struct sk_buff *skb,const struct mptcp_sock *msk,const struct sock *ssk) +{ +if (mptcp_event_sub_established (skb, msk, ssk)) +return -EMSGSIZE ; + +return 0 ; +} + +static int mptcp_event_created (struct sk_buff *skb,const struct mptcp_sock *msk,const struct sock *ssk) +{ +int err =nla_put_u32 (skb,MPTCP_ATTR_TOKEN , msk->token); + +if (err) +return err; + +return mptcp_event_add_subflow (skb, ssk); +} + +void mptcp_event_addr_removed (const struct mptcp_sock *msk,uint8_t id) +{ +struct net *net =sock_net ((const struct sock *)msk); +struct nlmsghdr *nlh; +struct sk_buff *skb; + +if (!genl_has_listeners (&mptcp_genl_family, net,MPTCP_PM_EV_GRP_OFFSET )) +return ; + + skb =nlmsg_new (NLMSG_DEFAULT_SIZE ,GFP_ATOMIC ); +if (!skb) +return ;
net/mptcp/pm_netlink.c static int mptcp_nl_cmd_set_flags(struct sk_buff *skb, struct genl_info *info) · line 1398
Quoted 10 lines
net/mptcp/pm_netlink.c +10
-0+ + nlh =genlmsg_put (skb,0 ,0 , &mptcp_genl_family,0 ,MPTCP_EVENT_REMOVED ); +if (!nlh) + goto nla_put_failure; + +if (nla_put_u32 (skb,MPTCP_ATTR_TOKEN , msk->token)) + goto nla_put_failure; + +if (nla_put_u32 (skb,MPTCP_ATTR_REM_ID , id)) + goto nla_put_failure;
Matthieu already noted this, but MPTCP_ATTR_REM_ID is a u8.
Quoted 20 lines
net/mptcp/pm_netlink.c +20
-0+ +genlmsg_end (skb, nlh); +return mptcp_nl_mcast_send (net, skb,GFP_ATOMIC ); + +nla_put_failure: +kfree_skb (skb); +} + +void mptcp_event_addr_announced (const struct mptcp_sock *msk,const struct mptcp_addr_info *info) +{ +struct net *net =sock_net ((const struct sock *)msk); +struct nlmsghdr *nlh; +struct sk_buff *skb; + +if (!genl_has_listeners (&mptcp_genl_family, net,MPTCP_PM_EV_GRP_OFFSET )) +return ; + + skb =nlmsg_new (NLMSG_DEFAULT_SIZE ,GFP_ATOMIC ); +if (!skb) +return ;
net/mptcp/pm_netlink.c static int mptcp_nl_cmd_set_flags(struct sk_buff *skb, struct genl_info *info) · line 1428
Quoted 10 lines
net/mptcp/pm_netlink.c +10
-0+ + nlh =genlmsg_put (skb,0 ,0 , &mptcp_genl_family,0 ,MPTCP_EVENT_ANNOUNCED ); +if (!nlh) + goto nla_put_failure; + +if (nla_put_u32 (skb,MPTCP_ATTR_TOKEN , msk->token)) + goto nla_put_failure; + +if (nla_put_u32 (skb,MPTCP_ATTR_REM_ID , info->id)) + goto nla_put_failure;
Another REM_ID attribute that should be a u8.
--
Mat Martineau
Intel
Florian Westphal
[MPTCP] Re: [PATCH mptcp 7/7] mptcp: add netlink event support
Quoted 12 lines · Mat Martineau
Quoted 10 lines · Florian Westphal
Allow userspace (mptcpd) to subscribe to mptcp genl multicast events. This implementation reuses the same event API as the mptcp kernel fork to ease integration of existing tools, e.g. mptcpd.
Supported events include:
1. start and close of an mptcp connection
2. start and close of subflows (joins)
3. announce and withdrawals of addresses
4. subflow priority (backup/non-backup) change.
Quoted 5 lines
Quoted 1 line
Signed-off-by Florian Westphal <fw(a)strlen.de>Thanks for the patch series, Florian. I have a few minor comments below, and will work with Ossama to get mptcpd listening to the events on the upstream kernel and really test things out.
Thanks, that would help a lot.
Quoted 5 lines
Quoted 3 lines
#define
MPTCP_PM_NAME"mptcp_pm"
#defineMPTCP_PM_CMD_GRP_NAME"mptcp_pm_cmds"
+#defineMPTCP_PM_EV_GRP_NAME"mptcp_events"Suggest "
mptcp_pm_events" instead.
I don't mind changing it but it would mean one more change needed on mptcpd side vs. the out of tree kernel.
Matthieu Baerts
[MPTCP] Re: [PATCH mptcp 7/7] mptcp: add netlink event support
Hi Florian,
Quoted 10 lines · Florian Westphal
Quoted 6 lines · Mat Martineau
Quoted 3 lines · Florian Westphal
#define
MPTCP_PM_NAME"mptcp_pm"
#defineMPTCP_PM_CMD_GRP_NAME"mptcp_pm_cmds"
+#defineMPTCP_PM_EV_GRP_NAME"mptcp_events"Suggest "
mptcp_pm_events" instead.I don't mind changing it but it would mean one more change needed on mptcpd side vs. the out of tree kernel.
Instinctively, I would prefer having different names just in case we need to do something different from one implementation to another. In userspace, we would only have to try one or the other but at least we will know which one we are connected to, "just in case" we need different behaviours for one or the other.
Of course, if we are sure we are doing the same thing is both, that's fine to have the same name. I'm maybe feeling less confident just because there is no RFC for these events :)
(arf, I'm being influenced by the IETF :-O But I'm also fine with "mptcp_events" if we prefer!)
Cheers,
Matt
Signature · 2 lines
Tessares | Belgium | Hybrid Access Solutions www.tessares.net
Florian Westphal
[MPTCP] Re: [PATCH mptcp 7/7] mptcp: add netlink event support
Quoted 11 lines · Matthieu Baerts
Hi Florian,
Quoted 8 lines · Florian Westphal
Quoted 6 lines · Mat Martineau
Quoted 3 lines · Florian Westphal
#define
MPTCP_PM_NAME"mptcp_pm"
#defineMPTCP_PM_CMD_GRP_NAME"mptcp_pm_cmds"
+#defineMPTCP_PM_EV_GRP_NAME"mptcp_events"Suggest "
mptcp_pm_events" instead.
Quoted 8 lines
Quoted 2 lines
I don't mind changing it but it would mean one more change needed on mptcpd side vs. the out of tree kernel.
Instinctively, I would prefer having different names just in case we need to do something different from one implementation to another. In userspace, we would only have to try one or the other but at least we will know which one we are connected to, "just in case" we need different behaviours for one or the other.
mptcp kernel uses "mptcp" as the genetlink name, not "mptcp_pm", so it already knows if its running on mptcp.org or upstream kernel.
Matthieu Baerts
[MPTCP] Re: [PATCH mptcp 7/7] mptcp: add netlink event support
Quoted 15 lines · Florian Westphal
Quoted 14 lines · Matthieu Baerts
Hi Florian,
Quoted 10 lines · Florian Westphal
Quoted 6 lines · Mat Martineau
Quoted 3 lines · Florian Westphal
#define
MPTCP_PM_NAME"mptcp_pm"
#defineMPTCP_PM_CMD_GRP_NAME"mptcp_pm_cmds"
+#defineMPTCP_PM_EV_GRP_NAME"mptcp_events"Suggest "
mptcp_pm_events" instead.I don't mind changing it but it would mean one more change needed on mptcpd side vs. the out of tree kernel.
Quoted 8 lines
Quoted 5 lines
Instinctively, I would prefer having different names just in case we need to do something different from one implementation to another. In userspace, we would only have to try one or the other but at least we will know which one we are connected to, "just in case" we need different behaviours for one or the other.
mptcp kernel uses "mptcp" as the genetlink name, not "
mptcp_pm", so it already knows if its running on mptcp.org or upstream kernel.
Good point :)
Because the new "define" (MPTCP_PM_EV_GRP_NAME) has not the same name as in mptcp.org (MPTCP_GENL_EV_GRP_NAME) -- which makes sense -- I'm fine with either names, either prefixed with "mptcp_pm_" like the others here or the same as in mptcp.org. I guess the best is to wait for Ossama's point of view :)
Cheers,
Matt
Signature · 2 lines
Tessares | Belgium | Hybrid Access Solutions www.tessares.net