mptcp: use GENL_REQ_ATTR_CHECK in userspace pm
Subsystems (2)
Geliang Tang
reviewerv7 cover mptcp: use GENL_REQ_ATTR_CHECK in userspace pm
From: Geliang Tang <[email protected]>
v7:
- update set_flags() interface.
- drop 'info' parameter of userspace_pm_remove_id_zero_address().
- rebase v6 on top of these changes.
This is a newer version of the series started by Geliang, now making them more uniform on how the NL errors are set, and giving more hints to the userspace about what's wrong.
Geliang Tang (6):
mptcp: userspace pm set_flags id support
mptcp: drop skb parameter of set_flags
mptcp: change rem type of set_flags
mptcp: add local & remote parameters for set_flags
mptcp: drop info of userspace_pm_remove_id_zero_address
mptcp: pm: userspace: use GENL_REQ_ATTR_CHECK
Matthieu Baerts (NGI0) (5):
mptcp: pm: more precise error messages
mptcp: pm: use NL_SET_ERR_MSG_ATTR when possible
mptcp: pm: improve error messages
mptcp: pm: remove duplicated error messages
mptcp: pm: mark missing address attributes
net/mptcp/pm.c | 8 +- net/mptcp/pm_netlink.c | 107 +++++++++++++++++-------- net/mptcp/pm_userspace.c | 165 ++++++++++++++++++++------------------- net/mptcp/protocol.h | 12 ++- 4 files changed, 171 insertions(+), 121 deletions(-)
Signature · 1 line
2.45.2
Geliang Tang
reviewerPATCH v7 1/11 mptcp: pm: more precise error messages
From: "Matthieu Baerts (NGI0)" <[email protected]>
Some errors reported by the userspace PM were vague: "this or that is invalid".
It is easier for the userspace to know which part is wrong, instead of having to guess that.
By splitting some error messages, NL_SET_ERR_MSG_ATTR() can be used instead of GENL_SET_ERR_MSG() in order to give an additional hint to the userspace developers about which attribute is wrong.
--- net/mptcp/pm_userspace.c | 39 +++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-)
net/mptcp/pm_userspace.c +29 -10
@@ -223,8 +223,14 @@ int mptcp_pm_nl_announce_doit(struct sk_buff *skb, struct genl_info *info) goto announce_err; } -if (addr_val.addr.id ==0 || !(addr_val.flags &MPTCP_PM_ADDR_FLAG_SIGNAL )) { -GENL_SET_ERR_MSG (info,"invalid addr id or flags" ); +if (addr_val.addr.id ==0 ) { +NL_SET_ERR_MSG_ATTR (info->extack, addr,"invalid addr id" ); + err = -EINVAL ; + goto announce_err; + } + +if (!(addr_val.flags &MPTCP_PM_ADDR_FLAG_SIGNAL )) { +NL_SET_ERR_MSG_ATTR (info->extack, addr,"invalid addr flags" ); err = -EINVAL ; goto announce_err; }
@@ -530,8 +536,14 @@ int mptcp_pm_nl_subflow_destroy_doit(struct sk_buff *skb, struct genl_info *info goto destroy_err; } -if (!addr_l.addr.port || !addr_r.port) { -GENL_SET_ERR_MSG (info,"missing local or remote port" ); +if (!addr_l.addr.port) { +NL_SET_ERR_MSG_ATTR (info->extack, laddr,"missing local port" ); + err = -EINVAL ; + goto destroy_err; + } + +if (!addr_r.port) { +NL_SET_ERR_MSG_ATTR (info->extack, raddr,"missing remote port" ); err = -EINVAL ; goto destroy_err; }
@@ -579,17 +591,24 @@ int mptcp_userspace_pm_set_flags(struct sk_buff *skb, struct genl_info *info)if (ret <0 ) goto set_flags_err; +if (loc.addr.family ==AF_UNSPEC ) { +NL_SET_ERR_MSG_ATTR (info->extack, attr, +"invalid local address family" ); + ret = -EINVAL ; + goto set_flags_err; + } +if (attr_rem) { ret =mptcp_pm_parse_entry (attr_rem, info, false, &rem);if (ret <0 ) goto set_flags_err; - } -if (loc.addr.family ==AF_UNSPEC || - rem.addr.family ==AF_UNSPEC ) { -GENL_SET_ERR_MSG (info,"invalid address families" ); - ret = -EINVAL ; - goto set_flags_err; +if (rem.addr.family ==AF_UNSPEC ) { +NL_SET_ERR_MSG_ATTR (info->extack, attr_rem, +"invalid remote address family" ); + ret = -EINVAL ; + goto set_flags_err; + } }if (loc.flags &MPTCP_PM_ADDR_FLAG_BACKUP )
Signature · 1 line
2.45.2
Matthieu Baerts
maintainerRe: [PATCH mptcp-next v7 01/11] mptcp: pm: more precise error messages
Hi Geliang,
Quoted 5 lines · Geliang Tang
From: "Matthieu Baerts (NGI0)" <[email protected]>
Some errors reported by the userspace PM were vague: "this or that is invalid".
Quoted 8 lines
It is easier for the userspace to know which part is wrong, instead of having to guess that.
By splitting some error messages,
NL_SET_ERR_MSG_ATTR()can be used instead ofGENL_SET_ERR_MSG()in order to give an additional hint to the userspace developers about which attribute is wrong.Signed-off-by Matthieu Baerts (NGI0) <[email protected]>
If you modify the behaviour of a patch, you can add your 'co-dev' + 'sob' tags.
Also, please add an individual changelog, easier for the reviewers to spot what has changed.
Quoted 8 lines
--- net/mptcp/pm_userspace.c | 39 +++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-)net/mptcp/pm_userspace.c +0
-0
(...)
Quoted 13 lines
net/mptcp/pm_userspace.c +7
-0@@ -579,17 +591,24 @@ int mptcp_userspace_pm_set_flags(struct sk_buff *skb, struct genl_info *info)if (ret <0 ) goto set_flags_err; +if (loc.addr.family ==AF_UNSPEC ) { +NL_SET_ERR_MSG_ATTR (info->extack, attr, +"invalid local address family" ); + ret = -EINVAL ; + goto set_flags_err; + } +if (attr_rem) { ret =mptcp_pm_parse_entry (attr_rem, info, false, &rem);
net/mptcp/pm_userspace.c int mptcp_userspace_pm_set_flags(struct sk_buff *skb, struct genl_info *info) · line 606
Quoted 10 lines
net/mptcp/pm_userspace.c +1
-6if (ret <0 ) goto set_flags_err; - } -if (loc.addr.family ==AF_UNSPEC || - rem.addr.family ==AF_UNSPEC ) { -GENL_SET_ERR_MSG (info,"invalid address families" ); - ret = -EINVAL ; - goto set_flags_err; +if (rem.addr.family ==AF_UNSPEC ) {
As I mentioned in a previous version, this is changing the behaviour:
this remote attribute is no longer mandatory. I'm still unsure about making it optional, because mptcp_pm_nl_mp_prio_send_ack() will pick only one subflow, not all the ones with the specified local address. It looks better to keep it mandatory.
At least here, you should not move it under "if (attr_rem)".
(and maybe it makes more sense to have this patch after 07/11 ("mptcp:
pm: use NL_SET_ERR_MSG_ATTR when possible"), but that's a detail, fine here)
net/mptcp/pm_userspace.c int mptcp_userspace_pm_set_flags(struct sk_buff *skb, struct genl_info *info) · line 614
Quoted 8 lines
net/mptcp/pm_userspace.c +5
-0+NL_SET_ERR_MSG_ATTR (info->extack, attr_rem, +"invalid remote address family" ); + ret = -EINVAL ; + goto set_flags_err; + } }if (loc.flags &MPTCP_PM_ADDR_FLAG_BACKUP )
Cheers,
Matt
Signature · 1 line
Sponsored by the NGI0 Core fund.
Geliang Tang
reviewerPATCH v7 2/11 mptcp: userspace pm set_flags id support
In reply to Geliang TangFrom: Geliang Tang <[email protected]>
Similar to in-kernel PM, this patch adds address ID support to set_flags() interface of userspace PM, allowing it to work with either an address or an address ID.
When an address ID is used, mptcp_userspace_pm_lookup_addr_by_id() helper is used to look up the address entry in the local address list instead of using mptcp_userspace_pm_lookup_addr().
--- net/mptcp/pm_userspace.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-)
net/mptcp/pm_userspace.c +20 -11
@@ -577,6 +577,7 @@ int mptcp_userspace_pm_set_flags(struct sk_buff *skb, struct genl_info *info)struct nlattr *attr = info->attrs[MPTCP_PM_ATTR_ADDR ];struct mptcp_pm_addr_entry *entry;struct mptcp_sock *msk; +u8 lookup_by_id =0 ;int ret = -EINVAL ;struct sock *sk;u8 bkup =0 ;
@@ -592,10 +593,13 @@ int mptcp_userspace_pm_set_flags(struct sk_buff *skb, struct genl_info *info) goto set_flags_err;if (loc.addr.family ==AF_UNSPEC ) { -NL_SET_ERR_MSG_ATTR (info->extack, attr, -"invalid local address family" ); - ret = -EINVAL ; - goto set_flags_err; + lookup_by_id =1 ; +if (!loc.addr.id) { +NL_SET_ERR_MSG_ATTR (info->extack, attr, +"missing address ID" ); + ret = -EOPNOTSUPP ; + goto set_flags_err; + } }if (attr_rem) {
@@ -615,17 +619,22 @@ int mptcp_userspace_pm_set_flags(struct sk_buff *skb, struct genl_info *info) bkup =1 ;spin_lock_bh (&msk->pm.lock); - entry =mptcp_userspace_pm_lookup_addr (msk, &loc.addr); -if (entry) { -if (bkup) - entry->flags |=MPTCP_PM_ADDR_FLAG_BACKUP ; -else - entry->flags &= ~MPTCP_PM_ADDR_FLAG_BACKUP ; + entry = lookup_by_id ?mptcp_userspace_pm_lookup_addr_by_id (msk, loc.addr.id) : +mptcp_userspace_pm_lookup_addr (msk, &loc.addr); +if (!entry) { +spin_unlock_bh (&msk->pm.lock); + ret = -EINVAL ; + goto set_flags_err; } + +if (bkup) + entry->flags |=MPTCP_PM_ADDR_FLAG_BACKUP ; +else + entry->flags &= ~MPTCP_PM_ADDR_FLAG_BACKUP ;spin_unlock_bh (&msk->pm.lock);lock_sock (sk); - ret =mptcp_pm_nl_mp_prio_send_ack (msk, &loc.addr, &rem.addr, bkup); + ret =mptcp_pm_nl_mp_prio_send_ack (msk, &entry->addr, &rem.addr, bkup);release_sock (sk); set_flags_err:
Signature · 1 line
2.45.2
Matthieu Baerts
maintainerRe: [PATCH mptcp-next v7 02/11] mptcp: userspace pm set_flags id support
Hi Geliang,
Quoted 51 lines · Geliang Tang
From: Geliang Tang <[email protected]>
Similar to in-kernel PM, this patch adds address ID support to
set_flags()interface of userspace PM, allowing it to work with either an address or an address ID.When an address ID is used,
mptcp_userspace_pm_lookup_addr_by_id()helper is used to look up the address entry in the local address list instead of usingmptcp_userspace_pm_lookup_addr().Signed-off-by Geliang Tang <[email protected]>--- net/mptcp/pm_userspace.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-)net/mptcp/pm_userspace.c +8
-6@@ -577,6 +577,7 @@ int mptcp_userspace_pm_set_flags(struct sk_buff *skb, struct genl_info *info)struct nlattr *attr = info->attrs[MPTCP_PM_ATTR_ADDR ];struct mptcp_pm_addr_entry *entry;struct mptcp_sock *msk; +u8 lookup_by_id =0 ;int ret = -EINVAL ;struct sock *sk;u8 bkup =0 ;@@ -592,10 +593,13 @@ int mptcp_userspace_pm_set_flags(struct sk_buff *skb, struct genl_info *info) goto set_flags_err;if (loc.addr.family ==AF_UNSPEC ) { -NL_SET_ERR_MSG_ATTR (info->extack, attr, -"invalid local address family" ); - ret = -EINVAL ; - goto set_flags_err; + lookup_by_id =1 ; +if (!loc.addr.id) { +NL_SET_ERR_MSG_ATTR (info->extack, attr, +"missing address ID" ); + ret = -EOPNOTSUPP ; + goto set_flags_err; + } }if (attr_rem) {@@ -615,17 +619,22 @@ int mptcp_userspace_pm_set_flags(struct sk_buff *skb, struct genl_info *info) bkup =1 ;spin_lock_bh (&msk->pm.lock); - entry =mptcp_userspace_pm_lookup_addr (msk, &loc.addr); -if (entry) {
net/mptcp/pm_userspace.c int mptcp_userspace_pm_set_flags(struct sk_buff *skb, struct genl_info *info) · line 627
Quoted 10 lines
net/mptcp/pm_userspace.c +6
-4-if (bkup) - entry->flags |=MPTCP_PM_ADDR_FLAG_BACKUP ; -else - entry->flags &= ~MPTCP_PM_ADDR_FLAG_BACKUP ; + entry = lookup_by_id ?mptcp_userspace_pm_lookup_addr_by_id (msk, loc.addr.id) : +mptcp_userspace_pm_lookup_addr (msk, &loc.addr); +if (!entry) { +spin_unlock_bh (&msk->pm.lock); + ret = -EINVAL ; + goto set_flags_err;
Mmh, you are changing the behaviour here by making it mandatory to have an entry, and I don't think you can: if I'm not mistaken, with the userspace PM, it is possible not to find any entries here, e.g. if a subflow using this address has not been added or the address has not been announced (I guess the initial address is not there then).
Also, with the userspace PM, it is possible to have an entry with an ADDR ID == 0.
Do you think this patch is worth it? Setting by ID for the in-kernel PM makes sense: unique ID for the netns, easier to type the ID than the full address. While for the userspace PM, it will be managed by a daemon that will have to track addresses anyway.
Quoted 4 lines
net/mptcp/pm_userspace.c +3
-0} + +if (bkup) + entry->flags |=MPTCP_PM_ADDR_FLAG_BACKUP ;
net/mptcp/pm_userspace.c int mptcp_userspace_pm_set_flags(struct sk_buff *skb, struct genl_info *info) · line 640
Quoted 10 lines
net/mptcp/pm_userspace.c +3
-1+else + entry->flags &= ~MPTCP_PM_ADDR_FLAG_BACKUP ;spin_unlock_bh (&msk->pm.lock);lock_sock (sk); - ret =mptcp_pm_nl_mp_prio_send_ack (msk, &loc.addr, &rem.addr, bkup); + ret =mptcp_pm_nl_mp_prio_send_ack (msk, &entry->addr, &rem.addr, bkup);release_sock (sk); set_flags_err:
Cheers,
Matt
Signature · 1 line
Sponsored by the NGI0 Core fund.
Geliang Tang
reviewerPATCH v7 3/11 mptcp: drop skb parameter of set_flags
In reply to Geliang TangFrom: Geliang Tang <[email protected]>
The first parameter 'skb' in mptcp_pm_nl_set_flags() is only used to obtained the network namespace, which can also be obtained through the second parameters 'info' by using genl_info_net() helper. This patch drops these useless parameters 'skb' in all three set_flags() interfaces.
--- net/mptcp/pm.c | 6 +++--- net/mptcp/pm_netlink.c | 6 +++--- net/mptcp/pm_userspace.c | 2 +- net/mptcp/protocol.h | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-)
net/mptcp/pm.c +3 -3
@@ -449,11 +449,11 @@ int mptcp_pm_dump_addr(struct sk_buff *msg, struct netlink_callback *cb)return mptcp_pm_nl_dump_addr (msg, cb); } -int mptcp_pm_set_flags (struct sk_buff *skb,struct genl_info *info) +int mptcp_pm_set_flags (struct genl_info *info) {if (info->attrs[MPTCP_PM_ATTR_TOKEN ]) -return mptcp_userspace_pm_set_flags (skb, info); -return mptcp_pm_nl_set_flags (skb, info); +return mptcp_userspace_pm_set_flags (info); +return mptcp_pm_nl_set_flags (info); }void mptcp_pm_subflow_chk_stale (const struct mptcp_sock *msk,struct sock *ssk)
net/mptcp/pm_netlink.c +3 -3
@@ -1981,13 +1981,13 @@ static int mptcp_nl_set_flags(struct net *net,return ret; } -int mptcp_pm_nl_set_flags (struct sk_buff *skb,struct genl_info *info) +int mptcp_pm_nl_set_flags (struct genl_info *info) {struct mptcp_pm_addr_entry addr = { .addr = { .family =AF_UNSPEC }, };struct nlattr *attr = info->attrs[MPTCP_PM_ATTR_ADDR ];u8 changed, mask =MPTCP_PM_ADDR_FLAG_BACKUP |MPTCP_PM_ADDR_FLAG_FULLMESH ; -struct net *net =sock_net (skb->sk); +struct net *net =genl_info_net (info);struct mptcp_pm_addr_entry *entry;struct pm_nl_pernet *pernet;u8 lookup_by_id =0 ;
@@ -2037,7 +2037,7 @@ int mptcp_pm_nl_set_flags(struct sk_buff *skb, struct genl_info *info)int mptcp_pm_nl_set_flags_doit (struct sk_buff *skb,struct genl_info *info) { -return mptcp_pm_set_flags (skb, info); +return mptcp_pm_set_flags (info); }static void mptcp_nl_mcast_send (struct net *net,struct sk_buff *nlskb,gfp_t gfp)
net/mptcp/pm_userspace.c +1 -1
@@ -569,7 +569,7 @@ int mptcp_pm_nl_subflow_destroy_doit(struct sk_buff *skb, struct genl_info *inforeturn err; } -int mptcp_userspace_pm_set_flags (struct sk_buff *skb,struct genl_info *info) +int mptcp_userspace_pm_set_flags (struct genl_info *info) {struct mptcp_pm_addr_entry loc = { .addr = { .family =AF_UNSPEC }, };struct mptcp_pm_addr_entry rem = { .addr = { .family =AF_UNSPEC }, };
net/mptcp/protocol.h +3 -3
@@ -1028,9 +1028,9 @@ bool mptcp_lookup_subflow_by_saddr(const struct list_head *list, const struct mptcp_addr_info *saddr);bool mptcp_remove_anno_list_by_saddr (struct mptcp_sock *msk,const struct mptcp_addr_info *addr); -int mptcp_pm_set_flags (struct sk_buff *skb,struct genl_info *info); -int mptcp_pm_nl_set_flags (struct sk_buff *skb,struct genl_info *info); -int mptcp_userspace_pm_set_flags (struct sk_buff *skb,struct genl_info *info); +int mptcp_pm_set_flags (struct genl_info *info); +int mptcp_pm_nl_set_flags (struct genl_info *info); +int mptcp_userspace_pm_set_flags (struct genl_info *info);int mptcp_pm_announce_addr (struct mptcp_sock *msk,const struct mptcp_addr_info *addr,bool echo);
Signature · 1 line
2.45.2
Geliang Tang
reviewerPATCH v7 4/11 mptcp: change rem type of set_flags
In reply to Geliang TangFrom: Geliang Tang <[email protected]>
Generally, in the path manager interfaces, the local address is defined as an mptcp_pm_addr_entry type address, while the remote address is defined as an mptcp_addr_info type one:
(struct mptcp_pm_addr_entry *local, struct mptcp_addr_info *remote)
But the set_flags() interface uses two mptcp_pm_addr_entry type parameters. This patch changes the second one to mptcp_addr_info type and use helper mptcp_pm_parse_addr() to parse it instead of using mptcp_pm_parse_entry().
--- net/mptcp/pm_userspace.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
net/mptcp/pm_userspace.c +4 -4
@@ -572,9 +572,9 @@ int mptcp_pm_nl_subflow_destroy_doit(struct sk_buff *skb, struct genl_info *infoint mptcp_userspace_pm_set_flags (struct genl_info *info) {struct mptcp_pm_addr_entry loc = { .addr = { .family =AF_UNSPEC }, }; -struct mptcp_pm_addr_entry rem = { .addr = { .family =AF_UNSPEC }, };struct nlattr *attr_rem = info->attrs[MPTCP_PM_ATTR_ADDR_REMOTE ];struct nlattr *attr = info->attrs[MPTCP_PM_ATTR_ADDR ]; +struct mptcp_addr_info rem = { .family =AF_UNSPEC , };struct mptcp_pm_addr_entry *entry;struct mptcp_sock *msk;u8 lookup_by_id =0 ;
@@ -603,11 +603,11 @@ int mptcp_userspace_pm_set_flags(struct genl_info *info) }if (attr_rem) { - ret =mptcp_pm_parse_entry (attr_rem, info, false, &rem); + ret =mptcp_pm_parse_addr (attr_rem, info, &rem);if (ret <0 ) goto set_flags_err; -if (rem.addr.family ==AF_UNSPEC ) { +if (rem.family ==AF_UNSPEC ) {NL_SET_ERR_MSG_ATTR (info->extack, attr_rem,"invalid remote address family" ); ret = -EINVAL ;
@@ -634,7 +634,7 @@ int mptcp_userspace_pm_set_flags(struct genl_info *info)spin_unlock_bh (&msk->pm.lock);lock_sock (sk); - ret =mptcp_pm_nl_mp_prio_send_ack (msk, &entry->addr, &rem.addr, bkup); + ret =mptcp_pm_nl_mp_prio_send_ack (msk, &entry->addr, &rem, bkup);release_sock (sk); set_flags_err:
Signature · 1 line
2.45.2
Geliang Tang
reviewerPATCH v7 5/11 mptcp: add local & remote parameters for set_flags
In reply to Geliang TangFrom: Geliang Tang <[email protected]>
This patch updates the interfaces set_flags to reduce repetitive code, adds two more parameters 'local' and 'remote' for them. These addresses are parsed in public helper mptcp_pm_nl_set_flags_doit(), then pass them to mptcp_pm_nl_set_flags() and mptcp_userspace_pm_set_flags().
--- net/mptcp/pm.c | 8 +++-- net/mptcp/pm_netlink.c | 70 +++++++++++++++++++++++++++------------- net/mptcp/pm_userspace.c | 43 +++++------------------- net/mptcp/protocol.h | 12 +++++-- 4 files changed, 69 insertions(+), 64 deletions(-)
net/mptcp/pm.c +5 -3
@@ -449,11 +449,13 @@ int mptcp_pm_dump_addr(struct sk_buff *msg, struct netlink_callback *cb)return mptcp_pm_nl_dump_addr (msg, cb); } -int mptcp_pm_set_flags (struct genl_info *info) +int mptcp_pm_set_flags (struct mptcp_pm_addr_entry *local, +struct mptcp_addr_info *remote, +struct genl_info *info) {if (info->attrs[MPTCP_PM_ATTR_TOKEN ]) -return mptcp_userspace_pm_set_flags (info); -return mptcp_pm_nl_set_flags (info); +return mptcp_userspace_pm_set_flags (local, remote, info); +return mptcp_pm_nl_set_flags (local, remote, info); }void mptcp_pm_subflow_chk_stale (const struct mptcp_sock *msk,struct sock *ssk)
net/mptcp/pm_netlink.c +47 -23
109 lines not on this page · raw message
net/mptcp/pm_userspace.c +8 -35
69 lines not on this page · raw message
net/mptcp/protocol.h +9 -3
@@ -1028,9 +1028,15 @@ bool mptcp_lookup_subflow_by_saddr(const struct list_head *list, const struct mptcp_addr_info *saddr);bool mptcp_remove_anno_list_by_saddr (struct mptcp_sock *msk,const struct mptcp_addr_info *addr); -int mptcp_pm_set_flags (struct genl_info *info); -int mptcp_pm_nl_set_flags (struct genl_info *info); -int mptcp_userspace_pm_set_flags (struct genl_info *info); +int mptcp_pm_set_flags (struct mptcp_pm_addr_entry *local, +struct mptcp_addr_info *remote, +struct genl_info *info); +int mptcp_pm_nl_set_flags (struct mptcp_pm_addr_entry *local, +struct mptcp_addr_info *remote, +struct genl_info *info); +int mptcp_userspace_pm_set_flags (struct mptcp_pm_addr_entry *local, +struct mptcp_addr_info *remote, +struct genl_info *info);int mptcp_pm_announce_addr (struct mptcp_sock *msk,const struct mptcp_addr_info *addr,bool echo);
Signature · 1 line
2.45.2
Matthieu Baerts
maintainerRe: [PATCH mptcp-next v7 05/11] mptcp: add local & remote parameters for set_flags
Hi Geliang,
Quoted 6 lines · Geliang Tang
From: Geliang Tang <[email protected]>
This patch updates the interfaces
set_flagsto reduce repetitive code, adds two more parameters 'local' and 'remote' for them. These addresses are parsed in public helpermptcp_pm_nl_set_flags_doit(), then pass them tomptcp_pm_nl_set_flags()andmptcp_userspace_pm_set_flags().
Because the in-kernel and userspace PM have different requirements:
token and remote addr only for the userspace PM, search by local addr ID probably only for the in-kernel, etc. it might be clearer to keep them separated.
At the end, I think only the parsing of the local address can be done for both (mptcp_pm_parse_entry()). Maybe not worth it to move only this part? WDYT?
Cheers,
Matt
Signature · 1 line
Sponsored by the NGI0 Core fund.
Matthieu Baerts
maintainerRe: [PATCH mptcp-next v7 05/11] mptcp: add local & remote parameters for set_flags
Hi Geliang,
Quoted 10 lines · Matthieu Baerts
Hi Geliang,
Quoted 6 lines · Geliang Tang
From: Geliang Tang <[email protected]>
This patch updates the interfaces
set_flagsto reduce repetitive code, adds two more parameters 'local' and 'remote' for them. These addresses are parsed in public helpermptcp_pm_nl_set_flags_doit(), then pass them tomptcp_pm_nl_set_flags()andmptcp_userspace_pm_set_flags().
Quoted 8 lines
Because the in-kernel and userspace PM have different requirements:
token and remote addr only for the userspace PM, search by local addr ID probably only for the in-kernel, etc. it might be clearer to keep them separated.At the end, I think only the parsing of the local address can be done for both (
mptcp_pm_parse_entry()). Maybe not worth it to move only this part? WDYT?
Just in case you drop this patch, please note that in my v6, I was also modifying the two set_flags() helpers in different patches:
- The split without changing the behaviour in "mptcp: pm: more precise error messages"
- Keeping "mptcp: pm: userspace: flags: clearer msg if no remote addr"
- Using NL_SET_ERR_MSG_ATTR() in "mptcp: pm: use NL_SET_ERR_MSG_ATTR when possible"
- "missing address ID" message in "mptcp: pm: improve error messages"
- Adding GENL_REQ_ATTR_CHECK() in "mptcp: pm: mark missing address attributes"
Make sure to compare your future v8 with the v6 ;)
Cheers,
Matt
Signature · 1 line
Sponsored by the NGI0 Core fund.
Geliang Tang
reviewerPATCH v7 6/11 mptcp: drop info of userspace_pm_remove_id_zero_address
In reply to Geliang TangFrom: Geliang Tang <[email protected]>
The only use of 'info' parameter of userspace_pm_remove_id_zero_address() is to set an error message into it.
This patch drops this parameter and sets the error message where this function is called in mptcp_pm_nl_remove_doit().
--- net/mptcp/pm_userspace.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
net/mptcp/pm_userspace.c +8 -7
@@ -259,8 +259,7 @@ int mptcp_pm_nl_announce_doit(struct sk_buff *skb, struct genl_info *info)return err; } -static int mptcp_userspace_pm_remove_id_zero_address (struct mptcp_sock *msk, -struct genl_info *info) +static int mptcp_userspace_pm_remove_id_zero_address (struct mptcp_sock *msk) {struct mptcp_rm_list list = { .nr =0 };struct mptcp_subflow_context *subflow;
@@ -275,10 +274,8 @@ static int mptcp_userspace_pm_remove_id_zero_address(struct mptcp_sock *msk,break ; } } -if (!has_id_0) { -GENL_SET_ERR_MSG (info,"address with id 0 not found" ); +if (!has_id_0) goto remove_err; - } list.ids[list.nr++] =0 ;
@@ -336,7 +333,7 @@ int mptcp_pm_nl_remove_doit(struct sk_buff *skb, struct genl_info *info) sk = (struct sock *)msk;if (id_val ==0 ) { - err =mptcp_userspace_pm_remove_id_zero_address (msk, info); + err =mptcp_userspace_pm_remove_id_zero_address (msk); goto out; }
@@ -345,7 +342,6 @@ int mptcp_pm_nl_remove_doit(struct sk_buff *skb, struct genl_info *info)spin_lock_bh (&msk->pm.lock); match =mptcp_userspace_pm_lookup_addr_by_id (msk, id_val);if (!match) { -GENL_SET_ERR_MSG (info,"address with specified id not found" );spin_unlock_bh (&msk->pm.lock);release_sock (sk); goto out;
@@ -362,6 +358,11 @@ int mptcp_pm_nl_remove_doit(struct sk_buff *skb, struct genl_info *info) err =0 ; out: +if (err) +GENL_SET_ERR_MSG_FMT (info, +"address with id %u not found" , + id_val); +sock_put (sk);return err; }
Signature · 1 line
2.45.2
Matthieu Baerts
maintainerRe: [PATCH mptcp-next v7 06/11] mptcp: drop info of userspace_pm_remove_id_zero_address
Quoted 4 lines · Geliang Tang
From: Geliang Tang <[email protected]>
The only use of 'info' parameter of
userspace_pm_remove_id_zero_address()is to set an error message into it.
Can you add:
Plus, this helper will only fail when it cannot find any subflows with a local address ID 0.
(Because if there were different types of errors, you could not drop 'info').
Quoted 53 lines
This patch drops this parameter and sets the error message where this function is called in
mptcp_pm_nl_remove_doit().Signed-off-by Geliang Tang <[email protected]>--- net/mptcp/pm_userspace.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)net/mptcp/pm_userspace.c +3
-7@@ -259,8 +259,7 @@ int mptcp_pm_nl_announce_doit(struct sk_buff *skb, struct genl_info *info)return err; } -static int mptcp_userspace_pm_remove_id_zero_address (struct mptcp_sock *msk, -struct genl_info *info) +static int mptcp_userspace_pm_remove_id_zero_address (struct mptcp_sock *msk) {struct mptcp_rm_list list = { .nr =0 };struct mptcp_subflow_context *subflow;@@ -275,10 +274,8 @@ static int mptcp_userspace_pm_remove_id_zero_address(struct mptcp_sock *msk,break ; } } -if (!has_id_0) { -GENL_SET_ERR_MSG (info,"address with id 0 not found" ); +if (!has_id_0) goto remove_err; - } list.ids[list.nr++] =0 ;@@ -336,7 +333,7 @@ int mptcp_pm_nl_remove_doit(struct sk_buff *skb, struct genl_info *info) sk = (struct sock *)msk;if (id_val ==0 ) { - err =mptcp_userspace_pm_remove_id_zero_address (msk, info); + err =mptcp_userspace_pm_remove_id_zero_address (msk); goto out; }@@ -345,7 +342,6 @@ int mptcp_pm_nl_remove_doit(struct sk_buff *skb, struct genl_info *info)spin_lock_bh (&msk->pm.lock); match =mptcp_userspace_pm_lookup_addr_by_id (msk, id_val);if (!match) { -GENL_SET_ERR_MSG (info,"address with specified id not found" );spin_unlock_bh (&msk->pm.lock);release_sock (sk); goto out;
net/mptcp/pm_userspace.c int mptcp_pm_nl_remove_doit(struct sk_buff *skb, struct genl_info *info) · line 362
Quoted 5 lines
net/mptcp/pm_userspace.c +2
-0@@ -362,6 +358,11 @@ int mptcp_pm_nl_remove_doit(struct sk_buff *skb, struct genl_info *info) err =0 ; out: +if (err) + GENL_SET_ERR_MSG_FMT(info,
Can you not use NL_SET_ERR_MSG_ATTR_FMT() here?
net/mptcp/pm_userspace.c int mptcp_pm_nl_remove_doit(struct sk_buff *skb, struct genl_info *info) · line 364
Quoted 2 lines
net/mptcp/pm_userspace.c +2
-0+"address with id %u not found" , + id_val);
Detail: in fact, I don't think it is needed to specify the ID in the error message to send to the userspace: the ID has been specified by the userspace, it knows what it has set. Up to you.
net/mptcp/pm_userspace.c int mptcp_pm_nl_remove_doit(struct sk_buff *skb, struct genl_info *info) · line 368
Quoted 4 lines
net/mptcp/pm_userspace.c +1
-0+sock_put (sk);return err; }
Cheers,
Matt
Signature · 1 line
Sponsored by the NGI0 Core fund.
Geliang Tang
reviewerPATCH v7 7/11 mptcp: pm: use NL_SET_ERR_MSG_ATTR when possible
In reply to Geliang TangFrom: "Matthieu Baerts (NGI0)" <[email protected]>
Instead of only returning a text message with GENL_SET_ERR_MSG(), NL_SET_ERR_MSG_ATTR() can help the userspace developers by also reporting which attribute is faulty.
When the error is specific to an attribute, NL_SET_ERR_MSG_ATTR() is now used. The error messages have not been modified in this commit.
mptcp_userspace_pm_remove_id_zero_address() has been modified to set the missing attribute.
--- net/mptcp/pm_netlink.c | 16 ++++++++++------ net/mptcp/pm_userspace.c | 13 ++++++++----- 2 files changed, 18 insertions(+), 11 deletions(-)
net/mptcp/pm_netlink.c +10 -6
@@ -1403,18 +1403,21 @@ int mptcp_pm_nl_add_addr_doit(struct sk_buff *skb, struct genl_info *info)return ret;if (addr.addr.port && !address_use_port (&addr)) { -GENL_SET_ERR_MSG (info,"flags must have signal and not subflow when using port" ); +NL_SET_ERR_MSG_ATTR (info->extack, attr, +"flags must have signal and not subflow when using port" );return -EINVAL ; }if (addr.flags &MPTCP_PM_ADDR_FLAG_SIGNAL && addr.flags &MPTCP_PM_ADDR_FLAG_FULLMESH ) { -GENL_SET_ERR_MSG (info,"flags mustn't have both signal and fullmesh" ); +NL_SET_ERR_MSG_ATTR (info->extack, attr, +"flags mustn't have both signal and fullmesh" );return -EINVAL ; }if (addr.flags &MPTCP_PM_ADDR_FLAG_IMPLICIT ) { -GENL_SET_ERR_MSG (info,"can't create IMPLICIT endpoint" ); +NL_SET_ERR_MSG_ATTR (info->extack, attr, +"can't create IMPLICIT endpoint" );return -EINVAL ; }
@@ -1608,7 +1611,7 @@ int mptcp_pm_nl_del_addr_doit(struct sk_buff *skb, struct genl_info *info)spin_lock_bh (&pernet->lock); entry =__lookup_addr_by_id (pernet, addr.addr.id);if (!entry) { -GENL_SET_ERR_MSG (info,"address not found" ); +NL_SET_ERR_MSG_ATTR (info->extack, attr,"address not found" );spin_unlock_bh (&pernet->lock);return -EINVAL ; }
@@ -1790,7 +1793,7 @@ int mptcp_pm_nl_get_addr(struct sk_buff *skb, struct genl_info *info)rcu_read_lock (); entry =__lookup_addr_by_id (pernet, addr.addr.id);if (!entry) { -GENL_SET_ERR_MSG (info,"address not found" ); +NL_SET_ERR_MSG_ATTR (info->extack, attr,"address not found" ); ret = -EINVAL ; goto unlock_fail; }
@@ -1875,7 +1878,8 @@ static int parse_limit(struct genl_info *info, int id, unsigned int *limit) *limit =nla_get_u32 (attr);if (*limit >MPTCP_PM_ADDR_MAX ) { -GENL_SET_ERR_MSG (info,"limit greater than maximum" ); +NL_SET_ERR_MSG_ATTR (info->extack, attr, +"limit greater than maximum" );return -EINVAL ; }return 0 ;
net/mptcp/pm_userspace.c +8 -5
@@ -190,7 +190,8 @@ static struct mptcp_sock *mptcp_userspace_pm_get_sock(const struct genl_info *in }if (!mptcp_pm_is_userspace (msk)) { -GENL_SET_ERR_MSG (info,"invalid request; userspace PM not selected" ); +NL_SET_ERR_MSG_ATTR (info->extack, token, +"invalid request; userspace PM not selected" );sock_put ((struct sock *)msk);return NULL ; }
@@ -237,7 +238,8 @@ int mptcp_pm_nl_announce_doit(struct sk_buff *skb, struct genl_info *info) err =mptcp_userspace_pm_append_new_local_addr (msk, &addr_val, false);if (err <0 ) { -GENL_SET_ERR_MSG (info,"did not match address and id" ); +NL_SET_ERR_MSG_ATTR (info->extack, addr, +"did not match address and id" ); goto announce_err; }
@@ -396,7 +398,7 @@ int mptcp_pm_nl_subflow_create_doit(struct sk_buff *skb, struct genl_info *info) }if (entry.flags &MPTCP_PM_ADDR_FLAG_SIGNAL ) { -GENL_SET_ERR_MSG (info,"invalid addr flags" ); +NL_SET_ERR_MSG_ATTR (info->extack, laddr,"invalid addr flags" ); err = -EINVAL ; goto create_err; }
@@ -416,7 +418,8 @@ int mptcp_pm_nl_subflow_create_doit(struct sk_buff *skb, struct genl_info *info) err =mptcp_userspace_pm_append_new_local_addr (msk, &entry, false);if (err <0 ) { -GENL_SET_ERR_MSG (info,"did not match address and id" ); +NL_SET_ERR_MSG_ATTR (info->extack, laddr, +"did not match address and id" ); goto create_err; }
@@ -704,7 +707,7 @@ int mptcp_userspace_pm_get_addr(struct sk_buff *skb,spin_lock_bh (&msk->pm.lock); entry =mptcp_userspace_pm_lookup_addr_by_id (msk, addr.addr.id);if (!entry) { -GENL_SET_ERR_MSG (info,"address not found" ); +NL_SET_ERR_MSG_ATTR (info->extack, attr,"address not found" ); ret = -EINVAL ; goto unlock_fail; }
Signature · 1 line
2.45.2
Matthieu Baerts
maintainerRe: [PATCH mptcp-next v7 07/11] mptcp: pm: use NL_SET_ERR_MSG_ATTR when possible
Hi Geliang,
Quoted 11 lines · Geliang Tang
From: "Matthieu Baerts (NGI0)" <[email protected]>
Instead of only returning a text message with
GENL_SET_ERR_MSG(),NL_SET_ERR_MSG_ATTR()can help the userspace developers by also reporting which attribute is faulty.When the error is specific to an attribute,
NL_SET_ERR_MSG_ATTR()is now used. The error messages have not been modified in this commit.
mptcp_userspace_pm_remove_id_zero_address()has been modified to set the missing attribute.
It is no longer the case. Can you remove these 2 lines please?
Cheers,
Matt
Signature · 1 line
Sponsored by the NGI0 Core fund.
Geliang Tang
reviewerPATCH v7 8/11 mptcp: pm: improve error messages
In reply to Geliang TangFrom: "Matthieu Baerts (NGI0)" <[email protected]>
Some error messages were:
- too generic: "missing input", "invalid request"
- not precise enough: "limit greater than maximum" but what's the max?
- missing: subflow not found, or connect error.
This can be easily improved by being more precise, or adding new error messages.
--- net/mptcp/pm_netlink.c | 5 +++-- net/mptcp/pm_userspace.c | 7 ++++++- 2 files changed, 9 insertions(+), 3 deletions(-)
net/mptcp/pm_netlink.c +3 -2
@@ -1878,8 +1878,9 @@ static int parse_limit(struct genl_info *info, int id, unsigned int *limit) *limit =nla_get_u32 (attr);if (*limit >MPTCP_PM_ADDR_MAX ) { -NL_SET_ERR_MSG_ATTR (info->extack, attr, -"limit greater than maximum" ); +NL_SET_ERR_MSG_ATTR_FMT (info->extack, attr, +"limit greater than maximum (%u)" , +MPTCP_PM_ADDR_MAX );return -EINVAL ; }return 0 ;
net/mptcp/pm_userspace.c +6 -1
@@ -191,7 +191,7 @@ static struct mptcp_sock *mptcp_userspace_pm_get_sock(const struct genl_info *inif (!mptcp_pm_is_userspace (msk)) {NL_SET_ERR_MSG_ATTR (info->extack, token, -"invalid request; userspace PM not selected" ); +"userspace PM not selected" );sock_put ((struct sock *)msk);return NULL ; }
@@ -430,6 +430,8 @@ int mptcp_pm_nl_subflow_create_doit(struct sk_buff *skb, struct genl_info *info)lock_sock (sk); err =__mptcp_subflow_connect (sk, &local, &addr_r);release_sock (sk); +if (err) +GENL_SET_ERR_MSG_FMT (info,"connect error: %d" , err);spin_lock_bh (&msk->pm.lock);if (err)
@@ -555,6 +557,7 @@ int mptcp_pm_nl_subflow_destroy_doit(struct sk_buff *skb, struct genl_info *infolock_sock (sk); ssk =mptcp_nl_find_ssk (msk, &addr_l.addr, &addr_r);if (!ssk) { +GENL_SET_ERR_MSG (info,"subflow not found" ); err = -ESRCH ; goto release_sock; }
@@ -613,6 +616,8 @@ int mptcp_userspace_pm_set_flags(struct mptcp_pm_addr_entry *local,lock_sock (sk); ret =mptcp_pm_nl_mp_prio_send_ack (msk, &entry->addr, remote, bkup);release_sock (sk); +if (ret) +GENL_SET_ERR_MSG (info,"mp_prio send ack failed" ); set_flags_err:sock_put (sk);
Signature · 1 line
2.45.2
Matthieu Baerts
maintainerRe: [PATCH mptcp-next v7 08/11] mptcp: pm: improve error messages
Hi Geliang,
Quoted 12 lines · Geliang Tang
From: "Matthieu Baerts (NGI0)" <[email protected]>
Some error messages were:
- too generic: "missing input", "invalid request"
- not precise enough: "limit greater than maximum" but what's the max?
- missing: subflow not found, or connect error.
This can be easily improved by being more precise, or adding new error messages.
(...)
Quoted 4 lines
net/mptcp/pm_userspace.c +0
-0
(...)
net/mptcp/pm_userspace.c int mptcp_userspace_pm_set_flags(struct mptcp_pm_addr_entry *local, · line 620
Quoted 6 lines
net/mptcp/pm_userspace.c +2
-0@@ -613,6 +616,8 @@ int mptcp_userspace_pm_set_flags(struct mptcp_pm_addr_entry *local,lock_sock (sk); ret =mptcp_pm_nl_mp_prio_send_ack (msk, &entry->addr, remote, bkup);release_sock (sk); +if (ret) +GENL_SET_ERR_MSG (info,"mp_prio send ack failed" );
As mentioned on my comment on the v6, it might be better to have:
/* mptcp_pm_nl_mp_prio_send_ack() only fails in one case */ if (ret < 0)
GENL_SET_ERR_MSG(info, "subflow not found");
net/mptcp/pm_userspace.c int mptcp_userspace_pm_set_flags(struct mptcp_pm_addr_entry *local, · line 623
Quoted 3 lines
net/mptcp/pm_userspace.c +0
-0set_flags_err:sock_put (sk);
Cheers,
Matt
Signature · 1 line
Sponsored by the NGI0 Core fund.
Geliang Tang
reviewerPATCH v7 9/11 mptcp: pm: userspace: use GENL_REQ_ATTR_CHECK
In reply to Geliang TangFrom: Geliang Tang <[email protected]>
A more general way to check if MPTCP_PM_ATTR_* exists in 'info' is to use GENL_REQ_ATTR_CHECK(info, MPTCP_PM_ATTR_*) instead of directly reading info->attrs[MPTCP_PM_ATTR_*] and then checking if it's NULL.
So this patch uses GENL_REQ_ATTR_CHECK() for userspace PM in mptcp_pm_nl_announce_doit(), mptcp_pm_nl_remove_doit(), mptcp_pm_nl_subflow_create_doit(), mptcp_pm_nl_subflow_destroy_doit() and mptcp_userspace_pm_get_sock().
--- net/mptcp/pm_userspace.c | 41 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 22 deletions(-)
net/mptcp/pm_userspace.c +19 -22
@@ -175,14 +175,13 @@ bool mptcp_userspace_pm_is_backup(struct mptcp_sock *msk,static struct mptcp_sock *mptcp_userspace_pm_get_sock (const struct genl_info *info) { -struct nlattr *token = info->attrs[MPTCP_PM_ATTR_TOKEN ];struct mptcp_sock *msk; +struct nlattr *token; -if (!token) { -GENL_SET_ERR_MSG (info,"missing required token" ); +if (GENL_REQ_ATTR_CHECK (info,MPTCP_PM_ATTR_TOKEN ))return NULL ; - } + token = info->attrs[MPTCP_PM_ATTR_TOKEN ]; msk =mptcp_token_get_sock (genl_info_net (info),nla_get_u32 (token));if (!msk) {NL_SET_ERR_MSG_ATTR (info->extack, token,"invalid token" );
@@ -201,16 +200,14 @@ static struct mptcp_sock *mptcp_userspace_pm_get_sock(const struct genl_info *inint mptcp_pm_nl_announce_doit (struct sk_buff *skb,struct genl_info *info) { -struct nlattr *addr = info->attrs[MPTCP_PM_ATTR_ADDR ];struct mptcp_pm_addr_entry addr_val;struct mptcp_sock *msk; +struct nlattr *addr;int err = -EINVAL ;struct sock *sk; -if (!addr) { -GENL_SET_ERR_MSG (info,"missing required address" ); +if (GENL_REQ_ATTR_CHECK (info,MPTCP_PM_ATTR_ADDR ))return err; - } msk =mptcp_userspace_pm_get_sock (info);if (!msk)
@@ -218,6 +215,7 @@ int mptcp_pm_nl_announce_doit(struct sk_buff *skb, struct genl_info *info) sk = (struct sock *)msk; + addr = info->attrs[MPTCP_PM_ATTR_ADDR ]; err =mptcp_pm_parse_entry (addr, info, true, &addr_val);if (err <0 ) {GENL_SET_ERR_MSG (info,"error parsing local address" );
@@ -314,18 +312,17 @@ void mptcp_pm_remove_addr_entry(struct mptcp_sock *msk,int mptcp_pm_nl_remove_doit (struct sk_buff *skb,struct genl_info *info) { -struct nlattr *id = info->attrs[MPTCP_PM_ATTR_LOC_ID ];struct mptcp_pm_addr_entry *match;struct mptcp_sock *msk; +struct nlattr *id;int err = -EINVAL ;struct sock *sk;u8 id_val; -if (!id) { -GENL_SET_ERR_MSG (info,"missing required ID" ); +if (GENL_REQ_ATTR_CHECK (info,MPTCP_PM_ATTR_LOC_ID ))return err; - } + id = info->attrs[MPTCP_PM_ATTR_LOC_ID ]; id_val =nla_get_u8 (id); msk =mptcp_userspace_pm_get_sock (info);
@@ -371,19 +368,17 @@ int mptcp_pm_nl_remove_doit(struct sk_buff *skb, struct genl_info *info)int mptcp_pm_nl_subflow_create_doit (struct sk_buff *skb,struct genl_info *info) { -struct nlattr *raddr = info->attrs[MPTCP_PM_ATTR_ADDR_REMOTE ]; -struct nlattr *laddr = info->attrs[MPTCP_PM_ATTR_ADDR ];struct mptcp_pm_addr_entry entry = {0 };struct mptcp_addr_info addr_r; +struct nlattr *raddr, *laddr;struct mptcp_pm_local local;struct mptcp_sock *msk;int err = -EINVAL ;struct sock *sk; -if (!laddr || !raddr) { -GENL_SET_ERR_MSG (info,"missing required address(es)" ); +if (GENL_REQ_ATTR_CHECK (info,MPTCP_PM_ATTR_ADDR ) || +GENL_REQ_ATTR_CHECK (info,MPTCP_PM_ATTR_ADDR_REMOTE ))return err; - } msk =mptcp_userspace_pm_get_sock (info);if (!msk)
@@ -391,6 +386,7 @@ int mptcp_pm_nl_subflow_create_doit(struct sk_buff *skb, struct genl_info *info) sk = (struct sock *)msk; + laddr = info->attrs[MPTCP_PM_ATTR_ADDR ]; err =mptcp_pm_parse_entry (laddr, info, true, &entry);if (err <0 ) {NL_SET_ERR_MSG_ATTR (info->extack, laddr,"error parsing local addr" );
@@ -404,6 +400,7 @@ int mptcp_pm_nl_subflow_create_doit(struct sk_buff *skb, struct genl_info *info) } entry.flags |=MPTCP_PM_ADDR_FLAG_SUBFLOW ; + raddr = info->attrs[MPTCP_PM_ATTR_ADDR_REMOTE ]; err =mptcp_pm_parse_addr (raddr, info, &addr_r);if (err <0 ) {NL_SET_ERR_MSG_ATTR (info->extack, raddr,"error parsing remote addr" );
@@ -495,18 +492,16 @@ static struct sock *mptcp_nl_find_ssk(struct mptcp_sock *msk,int mptcp_pm_nl_subflow_destroy_doit (struct sk_buff *skb,struct genl_info *info) { -struct nlattr *raddr = info->attrs[MPTCP_PM_ATTR_ADDR_REMOTE ]; -struct nlattr *laddr = info->attrs[MPTCP_PM_ATTR_ADDR ];struct mptcp_pm_addr_entry addr_l;struct mptcp_addr_info addr_r; +struct nlattr *raddr, *laddr;struct mptcp_sock *msk;struct sock *sk, *ssk;int err = -EINVAL ; -if (!laddr || !raddr) { -GENL_SET_ERR_MSG (info,"missing required address(es)" ); +if (GENL_REQ_ATTR_CHECK (info,MPTCP_PM_ATTR_ADDR ) || +GENL_REQ_ATTR_CHECK (info,MPTCP_PM_ATTR_ADDR_REMOTE ))return err; - } msk =mptcp_userspace_pm_get_sock (info);if (!msk)
@@ -514,12 +509,14 @@ int mptcp_pm_nl_subflow_destroy_doit(struct sk_buff *skb, struct genl_info *info sk = (struct sock *)msk; + laddr = info->attrs[MPTCP_PM_ATTR_ADDR ]; err =mptcp_pm_parse_entry (laddr, info, true, &addr_l);if (err <0 ) {NL_SET_ERR_MSG_ATTR (info->extack, laddr,"error parsing local addr" ); goto destroy_err; } + raddr = info->attrs[MPTCP_PM_ATTR_ADDR_REMOTE ]; err =mptcp_pm_parse_addr (raddr, info, &addr_r);if (err <0 ) {NL_SET_ERR_MSG_ATTR (info->extack, raddr,"error parsing remote addr" );
Signature · 1 line
2.45.2
Geliang Tang
reviewerPATCH v7 10/11 mptcp: pm: remove duplicated error messages
In reply to Geliang TangFrom: "Matthieu Baerts (NGI0)" <[email protected]>
mptcp_pm_parse_entry() and mptcp_pm_parse_addr() will already set a error message in case of parsing issue.
Then, no need to override this error message with another less precise
one: "error parsing address".
--- net/mptcp/pm_userspace.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-)
net/mptcp/pm_userspace.c +5 -15
@@ -217,10 +217,8 @@ int mptcp_pm_nl_announce_doit(struct sk_buff *skb, struct genl_info *info) addr = info->attrs[MPTCP_PM_ATTR_ADDR ]; err =mptcp_pm_parse_entry (addr, info, true, &addr_val); -if (err <0 ) { -GENL_SET_ERR_MSG (info,"error parsing local address" ); +if (err <0 ) goto announce_err; - }if (addr_val.addr.id ==0 ) {NL_SET_ERR_MSG_ATTR (info->extack, addr,"invalid addr id" );
@@ -388,10 +386,8 @@ int mptcp_pm_nl_subflow_create_doit(struct sk_buff *skb, struct genl_info *info) laddr = info->attrs[MPTCP_PM_ATTR_ADDR ]; err =mptcp_pm_parse_entry (laddr, info, true, &entry); -if (err <0 ) { -NL_SET_ERR_MSG_ATTR (info->extack, laddr,"error parsing local addr" ); +if (err <0 ) goto create_err; - }if (entry.flags &MPTCP_PM_ADDR_FLAG_SIGNAL ) {NL_SET_ERR_MSG_ATTR (info->extack, laddr,"invalid addr flags" );
@@ -402,10 +398,8 @@ int mptcp_pm_nl_subflow_create_doit(struct sk_buff *skb, struct genl_info *info) raddr = info->attrs[MPTCP_PM_ATTR_ADDR_REMOTE ]; err =mptcp_pm_parse_addr (raddr, info, &addr_r); -if (err <0 ) { -NL_SET_ERR_MSG_ATTR (info->extack, raddr,"error parsing remote addr" ); +if (err <0 ) goto create_err; - }if (!mptcp_pm_addr_families_match (sk, &entry.addr, &addr_r)) {GENL_SET_ERR_MSG (info,"families mismatch" );
@@ -511,17 +505,13 @@ int mptcp_pm_nl_subflow_destroy_doit(struct sk_buff *skb, struct genl_info *info laddr = info->attrs[MPTCP_PM_ATTR_ADDR ]; err =mptcp_pm_parse_entry (laddr, info, true, &addr_l); -if (err <0 ) { -NL_SET_ERR_MSG_ATTR (info->extack, laddr,"error parsing local addr" ); +if (err <0 ) goto destroy_err; - } raddr = info->attrs[MPTCP_PM_ATTR_ADDR_REMOTE ]; err =mptcp_pm_parse_addr (raddr, info, &addr_r); -if (err <0 ) { -NL_SET_ERR_MSG_ATTR (info->extack, raddr,"error parsing remote addr" ); +if (err <0 ) goto destroy_err; - }#if IS_ENABLED (CONFIG_MPTCP_IPV6 )if (addr_l.addr.family ==AF_INET &&ipv6_addr_v4mapped (&addr_r.addr6)) {
Signature · 1 line
2.45.2
Geliang Tang
reviewerPATCH v7 11/11 mptcp: pm: mark missing address attributes
In reply to Geliang TangFrom: "Matthieu Baerts (NGI0)" <[email protected]>
mptcp_pm_parse_entry() will check if the given attribute is defined. If not, it will return a generic error: "missing address info".
It might then not be clear for the userspace developer which attribute is missing, especially when the command takes multiple addresses.
By using GENL_REQ_ATTR_CHECK(), the userspace will get a hint about which attribute is missing, making thing clearer. Note that this is what was already done for most of the other MPTCP NL commands, this patch simply adds the missing ones.
--- net/mptcp/pm_netlink.c | 18 +++++++++++++++--- net/mptcp/pm_userspace.c | 6 +++++- 2 files changed, 20 insertions(+), 4 deletions(-)
net/mptcp/pm_netlink.c +15 -3
@@ -1393,11 +1393,15 @@ static bool mptcp_pm_has_addr_attr_id(const struct nlattr *attr,int mptcp_pm_nl_add_addr_doit (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);struct mptcp_pm_addr_entry addr, *entry; +struct nlattr *attr;int ret; +if (GENL_REQ_ATTR_CHECK (info,MPTCP_PM_ENDPOINT_ADDR )) +return -EINVAL ; + + attr = info->attrs[MPTCP_PM_ENDPOINT_ADDR ]; ret =mptcp_pm_parse_entry (attr, info, true, &addr);if (ret <0 )return ret;
@@ -1590,12 +1594,16 @@ static int mptcp_nl_remove_id_zero_address(struct net *net,int mptcp_pm_nl_del_addr_doit (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);struct mptcp_pm_addr_entry addr, *entry;unsigned int addr_max; +struct nlattr *attr;int ret; +if (GENL_REQ_ATTR_CHECK (info,MPTCP_PM_ENDPOINT_ADDR )) +return -EINVAL ; + + attr = info->attrs[MPTCP_PM_ENDPOINT_ADDR ]; ret =mptcp_pm_parse_entry (attr, info, false, &addr);if (ret <0 )return ret;
@@ -1767,13 +1775,17 @@ int mptcp_nl_fill_addr(struct sk_buff *skb,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);struct mptcp_pm_addr_entry addr, *entry;struct sk_buff *msg; +struct nlattr *attr;void *reply;int ret; +if (GENL_REQ_ATTR_CHECK (info,MPTCP_PM_ENDPOINT_ADDR )) +return -EINVAL ; + + attr = info->attrs[MPTCP_PM_ENDPOINT_ADDR ]; ret =mptcp_pm_parse_entry (attr, info, false, &addr);if (ret <0 )return ret;
net/mptcp/pm_userspace.c +5 -1
@@ -663,20 +663,24 @@ int mptcp_userspace_pm_dump_addr(struct sk_buff *msg,int mptcp_userspace_pm_get_addr (struct sk_buff *skb,struct genl_info *info) { -struct nlattr *attr = info->attrs[MPTCP_PM_ENDPOINT_ADDR ];struct mptcp_pm_addr_entry addr, *entry;struct mptcp_sock *msk;struct sk_buff *msg; +struct nlattr *attr;int ret = -EINVAL ;struct sock *sk;void *reply; +if (GENL_REQ_ATTR_CHECK (info,MPTCP_PM_ENDPOINT_ADDR )) +return ret; + msk =mptcp_userspace_pm_get_sock (info);if (!msk)return ret; sk = (struct sock *)msk; + attr = info->attrs[MPTCP_PM_ENDPOINT_ADDR ]; ret =mptcp_pm_parse_entry (attr, info, false, &addr);if (ret <0 ) goto out;
Signature · 1 line
2.45.2
Hi Matthieu,
Thank you for your modifications, that's great!
Our CI did some validations and here is its report:
- KVM Validation: normal: Unstable: 1 failed test(s): selftest_userspace_pm - Critical: 1 Call Trace(s) ❌
- KVM Validation: debug: Unstable: 2 failed test(s): packetdrill_fastopen selftest_userspace_pm - Critical: 1 Call Trace(s) ❌
- KVM Validation: btf-normal (only bpftest_all): Success! ✅
- KVM Validation: btf-debug (only bpftest_all): Success! ✅
- Task: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/12629204806
Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/1230ba468eda
Patchwork: https://patchwork.kernel.org/project/mptcp/list/?series=922462
If there are some issues, you can reproduce them using the same environment as the one used by the CI thanks to a docker image, e.g.:
$ cd [kernel source code]
$ docker run -v "${PWD}:${PWD}:rw" -w "${PWD}" --privileged --rm -it \
--pull always mptcp/mptcp-upstream-virtme-docker:latest \
auto-normalFor more details:
https://github.com/multipath-tcp/mptcp-upstream-virtme-docker
Please note that despite all the efforts that have been already done to have a stable tests suite when executed on a public CI like here, it is possible some reported issues are not due to your modifications. Still, do not hesitate to help us improve that ;-)
Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (NGI0 Core)