* [PATCH v1 1/3] string_helpers: Move string_is_valid() to the header
@ 2023-02-03 14:04 Andy Shevchenko
2023-02-03 14:05 ` [PATCH v1 2/3] genetlink: Use string_is_valid() helper Andy Shevchenko
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Andy Shevchenko @ 2023-02-03 14:04 UTC (permalink / raw)
To: Andy Shevchenko, Jakub Kicinski, Xin Long, linux-kernel, netdev,
dev, tipc-discussion
Cc: Andy Shevchenko, David S. Miller, Eric Dumazet, Paolo Abeni,
Pravin B Shelar, Jon Maloy, Ying Xue
Move string_is_valid() to the header for wider use.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
include/linux/string_helpers.h | 5 +++++
net/tipc/netlink_compat.c | 6 +-----
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/include/linux/string_helpers.h b/include/linux/string_helpers.h
index 88fb8e1d0421..01c9a432865a 100644
--- a/include/linux/string_helpers.h
+++ b/include/linux/string_helpers.h
@@ -12,6 +12,11 @@ struct device;
struct file;
struct task_struct;
+static inline bool string_is_valid(const char *s, int len)
+{
+ return memchr(s, '\0', len) ? true : false;
+}
+
/* Descriptions of the types of units to
* print in */
enum string_size_units {
diff --git a/net/tipc/netlink_compat.c b/net/tipc/netlink_compat.c
index dfea27a906f2..75186cd551a0 100644
--- a/net/tipc/netlink_compat.c
+++ b/net/tipc/netlink_compat.c
@@ -39,6 +39,7 @@
#include "node.h"
#include "net.h"
#include <net/genetlink.h>
+#include <linux/string_helpers.h>
#include <linux/tipc_config.h>
/* The legacy API had an artificial message length limit called
@@ -173,11 +174,6 @@ static struct sk_buff *tipc_get_err_tlv(char *str)
return buf;
}
-static inline bool string_is_valid(char *s, int len)
-{
- return memchr(s, '\0', len) ? true : false;
-}
-
static int __tipc_nl_compat_dumpit(struct tipc_nl_compat_cmd_dump *cmd,
struct tipc_nl_compat_msg *msg,
struct sk_buff *arg)
--
2.39.1
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH v1 2/3] genetlink: Use string_is_valid() helper
2023-02-03 14:04 [PATCH v1 1/3] string_helpers: Move string_is_valid() to the header Andy Shevchenko
@ 2023-02-03 14:05 ` Andy Shevchenko
2023-02-04 13:25 ` [ovs-dev] " Simon Horman
2023-02-03 14:05 ` [PATCH v1 3/3] openvswitch: " Andy Shevchenko
2023-02-04 13:25 ` [ovs-dev] [PATCH v1 1/3] string_helpers: Move string_is_valid() to the header Simon Horman
2 siblings, 1 reply; 6+ messages in thread
From: Andy Shevchenko @ 2023-02-03 14:05 UTC (permalink / raw)
To: Andy Shevchenko, Jakub Kicinski, Xin Long, linux-kernel, netdev,
dev, tipc-discussion
Cc: Andy Shevchenko, David S. Miller, Eric Dumazet, Paolo Abeni,
Pravin B Shelar, Jon Maloy, Ying Xue
Use string_is_valid() helper instead of cpecific memchr() call.
This shows better the intention of the call.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
net/netlink/genetlink.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
index 600993c80050..d7616c1bda93 100644
--- a/net/netlink/genetlink.c
+++ b/net/netlink/genetlink.c
@@ -13,7 +13,7 @@
#include <linux/errno.h>
#include <linux/types.h>
#include <linux/socket.h>
-#include <linux/string.h>
+#include <linux/string_helpers.h>
#include <linux/skbuff.h>
#include <linux/mutex.h>
#include <linux/bitmap.h>
@@ -457,7 +457,7 @@ static int genl_validate_assign_mc_groups(struct genl_family *family)
if (WARN_ON(grp->name[0] == '\0'))
return -EINVAL;
- if (WARN_ON(memchr(grp->name, '\0', GENL_NAMSIZ) == NULL))
+ if (WARN_ON(!string_is_valid(grp->name, GENL_NAMSIZ)))
return -EINVAL;
}
--
2.39.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [ovs-dev] [PATCH v1 2/3] genetlink: Use string_is_valid() helper
2023-02-03 14:05 ` [PATCH v1 2/3] genetlink: Use string_is_valid() helper Andy Shevchenko
@ 2023-02-04 13:25 ` Simon Horman
0 siblings, 0 replies; 6+ messages in thread
From: Simon Horman @ 2023-02-04 13:25 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Jakub Kicinski, Xin Long, linux-kernel, netdev, dev,
tipc-discussion, Andy Shevchenko, Jon Maloy, Eric Dumazet,
Ying Xue, Paolo Abeni, David S. Miller
On Fri, Feb 03, 2023 at 04:05:00PM +0200, Andy Shevchenko wrote:
> Use string_is_valid() helper instead of cpecific memchr() call.
> This shows better the intention of the call.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
For networking patches, the target tree, in this case net-next, should
appear in the patch subject:
[PATCH v1 net-next 1/3] genetlink: Use string_is_valid() helper
That notwithstanding,
Reviewed-by: Simon Horman <simon.horman@corigine.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v1 3/3] openvswitch: Use string_is_valid() helper
2023-02-03 14:04 [PATCH v1 1/3] string_helpers: Move string_is_valid() to the header Andy Shevchenko
2023-02-03 14:05 ` [PATCH v1 2/3] genetlink: Use string_is_valid() helper Andy Shevchenko
@ 2023-02-03 14:05 ` Andy Shevchenko
2023-02-04 13:26 ` [ovs-dev] " Simon Horman
2023-02-04 13:25 ` [ovs-dev] [PATCH v1 1/3] string_helpers: Move string_is_valid() to the header Simon Horman
2 siblings, 1 reply; 6+ messages in thread
From: Andy Shevchenko @ 2023-02-03 14:05 UTC (permalink / raw)
To: Andy Shevchenko, Jakub Kicinski, Xin Long, linux-kernel, netdev,
dev, tipc-discussion
Cc: Andy Shevchenko, David S. Miller, Eric Dumazet, Paolo Abeni,
Pravin B Shelar, Jon Maloy, Ying Xue
Use string_is_valid() helper instead of cpecific memchr() call.
This shows better the intention of the call.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
net/openvswitch/conntrack.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/net/openvswitch/conntrack.c b/net/openvswitch/conntrack.c
index 2172930b1f17..1d65805e79b4 100644
--- a/net/openvswitch/conntrack.c
+++ b/net/openvswitch/conntrack.c
@@ -9,6 +9,7 @@
#include <linux/udp.h>
#include <linux/sctp.h>
#include <linux/static_key.h>
+#include <linux/string_helpers.h>
#include <net/ip.h>
#include <net/genetlink.h>
#include <net/netfilter/nf_conntrack_core.h>
@@ -1383,7 +1384,7 @@ static int parse_ct(const struct nlattr *attr, struct ovs_conntrack_info *info,
#endif
case OVS_CT_ATTR_HELPER:
*helper = nla_data(a);
- if (!memchr(*helper, '\0', nla_len(a))) {
+ if (!string_is_valid(*helper, nla_len(a))) {
OVS_NLERR(log, "Invalid conntrack helper");
return -EINVAL;
}
@@ -1404,7 +1405,7 @@ static int parse_ct(const struct nlattr *attr, struct ovs_conntrack_info *info,
#ifdef CONFIG_NF_CONNTRACK_TIMEOUT
case OVS_CT_ATTR_TIMEOUT:
memcpy(info->timeout, nla_data(a), nla_len(a));
- if (!memchr(info->timeout, '\0', nla_len(a))) {
+ if (!string_is_valid(info->timeout, nla_len(a))) {
OVS_NLERR(log, "Invalid conntrack timeout");
return -EINVAL;
}
--
2.39.1
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [ovs-dev] [PATCH v1 3/3] openvswitch: Use string_is_valid() helper
2023-02-03 14:05 ` [PATCH v1 3/3] openvswitch: " Andy Shevchenko
@ 2023-02-04 13:26 ` Simon Horman
0 siblings, 0 replies; 6+ messages in thread
From: Simon Horman @ 2023-02-04 13:26 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Jakub Kicinski, Xin Long, linux-kernel, netdev, dev,
tipc-discussion, Andy Shevchenko, Jon Maloy, Eric Dumazet,
Ying Xue, Paolo Abeni, David S. Miller
On Fri, Feb 03, 2023 at 04:05:01PM +0200, Andy Shevchenko wrote:
> Use string_is_valid() helper instead of cpecific memchr() call.
> This shows better the intention of the call.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
For networking patches, the target tree, in this case net-next, should
appear in the patch subject:
[PATCH v1 net-next 3/3] openvswitch: Use string_is_valid()
That notwithstanding,
Reviewed-by: Simon Horman <simon.horman@corigine.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [ovs-dev] [PATCH v1 1/3] string_helpers: Move string_is_valid() to the header
2023-02-03 14:04 [PATCH v1 1/3] string_helpers: Move string_is_valid() to the header Andy Shevchenko
2023-02-03 14:05 ` [PATCH v1 2/3] genetlink: Use string_is_valid() helper Andy Shevchenko
2023-02-03 14:05 ` [PATCH v1 3/3] openvswitch: " Andy Shevchenko
@ 2023-02-04 13:25 ` Simon Horman
2 siblings, 0 replies; 6+ messages in thread
From: Simon Horman @ 2023-02-04 13:25 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Jakub Kicinski, Xin Long, linux-kernel, netdev, dev,
tipc-discussion, Andy Shevchenko, Jon Maloy, Eric Dumazet,
Ying Xue, Paolo Abeni, David S. Miller
On Fri, Feb 03, 2023 at 04:04:59PM +0200, Andy Shevchenko wrote:
> Move string_is_valid() to the header for wider use.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
For networking patches, the target tree, in this case net-next, should
appear in the patch subject:
[PATCH v1 net-next 1/3] string_helpers: Move string_is_valid()
That notwithstanding,
Reviewed-by: Simon Horman <simon.horman@corigine.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-02-04 13:26 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-03 14:04 [PATCH v1 1/3] string_helpers: Move string_is_valid() to the header Andy Shevchenko
2023-02-03 14:05 ` [PATCH v1 2/3] genetlink: Use string_is_valid() helper Andy Shevchenko
2023-02-04 13:25 ` [ovs-dev] " Simon Horman
2023-02-03 14:05 ` [PATCH v1 3/3] openvswitch: " Andy Shevchenko
2023-02-04 13:26 ` [ovs-dev] " Simon Horman
2023-02-04 13:25 ` [ovs-dev] [PATCH v1 1/3] string_helpers: Move string_is_valid() to the header Simon Horman
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.