Home Home > GIT Browse
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Kubecek <mkubecek@suse.cz>2019-02-14 14:03:24 +0100
committerMichal Kubecek <mkubecek@suse.cz>2019-02-14 14:03:24 +0100
commit79f04e32ff08ed75274ada9ee52bad0e31686f75 (patch)
tree90c0ff6d8277a4218f821d9c9465b272b4956faf
parentda8955a8cfbac7de855124f12ce06b14f93e7146 (diff)
kobject: add kobject_uevent_net_broadcast() (bsc#1122982).
-rw-r--r--patches.fixes/kobject-add-kobject_uevent_net_broadcast.patch136
-rw-r--r--series.conf1
2 files changed, 137 insertions, 0 deletions
diff --git a/patches.fixes/kobject-add-kobject_uevent_net_broadcast.patch b/patches.fixes/kobject-add-kobject_uevent_net_broadcast.patch
new file mode 100644
index 0000000000..b1aefbc3c5
--- /dev/null
+++ b/patches.fixes/kobject-add-kobject_uevent_net_broadcast.patch
@@ -0,0 +1,136 @@
+From: Eric Dumazet <edumazet@google.com>
+Date: Tue, 19 Sep 2017 16:27:03 -0700
+Subject: kobject: add kobject_uevent_net_broadcast()
+Patch-mainline: v4.15-rc1
+Git-commit: 16dff336b33d87c15d9cbe933cfd275aae2a8251
+References: bsc#1122982
+
+This removes some #ifdef pollution and will ease follow up patches.
+
+Signed-off-by: Eric Dumazet <edumazet@google.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+Acked-by: Michal Kubecek <mkubecek@suse.cz>
+
+---
+ lib/kobject_uevent.c | 96 ++++++++++++++++++++++++--------------------
+ 1 file changed, 53 insertions(+), 43 deletions(-)
+
+--- a/lib/kobject_uevent.c
++++ b/lib/kobject_uevent.c
+@@ -151,6 +151,57 @@ static void cleanup_uevent_env(struct subprocess_info *info)
+ }
+ #endif
+
++static int kobject_uevent_net_broadcast(struct kobject *kobj,
++ struct kobj_uevent_env *env,
++ const char *action_string,
++ const char *devpath)
++{
++ int retval = 0;
++#if defined(CONFIG_NET)
++ struct uevent_sock *ue_sk;
++
++ /* send netlink message */
++ list_for_each_entry(ue_sk, &uevent_sock_list, list) {
++ struct sock *uevent_sock = ue_sk->sk;
++ struct sk_buff *skb;
++ size_t len;
++
++ if (!netlink_has_listeners(uevent_sock, 1))
++ continue;
++
++ /* allocate message with the maximum possible size */
++ len = strlen(action_string) + strlen(devpath) + 2;
++ skb = alloc_skb(len + env->buflen, GFP_KERNEL);
++ if (skb) {
++ char *scratch;
++ int i;
++
++ /* add header */
++ scratch = skb_put(skb, len);
++ sprintf(scratch, "%s@%s", action_string, devpath);
++
++ /* copy keys to our continuous event payload buffer */
++ for (i = 0; i < env->envp_idx; i++) {
++ len = strlen(env->envp[i]) + 1;
++ scratch = skb_put(skb, len);
++ strcpy(scratch, env->envp[i]);
++ }
++
++ NETLINK_CB(skb).dst_group = 1;
++ retval = netlink_broadcast_filtered(uevent_sock, skb,
++ 0, 1, GFP_KERNEL,
++ kobj_bcast_filter,
++ kobj);
++ /* ENOBUFS should be handled in userspace */
++ if (retval == -ENOBUFS || retval == -ESRCH)
++ retval = 0;
++ } else
++ retval = -ENOMEM;
++ }
++#endif
++ return retval;
++}
++
+ /**
+ * kobject_uevent_env - send an uevent with environmental data
+ *
+@@ -173,9 +224,6 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
+ const struct kset_uevent_ops *uevent_ops;
+ int i = 0;
+ int retval = 0;
+-#ifdef CONFIG_NET
+- struct uevent_sock *ue_sk;
+-#endif
+
+ pr_debug("kobject: '%s' (%p): %s\n",
+ kobject_name(kobj), kobj, __func__);
+@@ -284,46 +332,8 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
+ mutex_unlock(&uevent_sock_mutex);
+ goto exit;
+ }
+-
+-#if defined(CONFIG_NET)
+- /* send netlink message */
+- list_for_each_entry(ue_sk, &uevent_sock_list, list) {
+- struct sock *uevent_sock = ue_sk->sk;
+- struct sk_buff *skb;
+- size_t len;
+-
+- if (!netlink_has_listeners(uevent_sock, 1))
+- continue;
+-
+- /* allocate message with the maximum possible size */
+- len = strlen(action_string) + strlen(devpath) + 2;
+- skb = alloc_skb(len + env->buflen, GFP_KERNEL);
+- if (skb) {
+- char *scratch;
+-
+- /* add header */
+- scratch = skb_put(skb, len);
+- sprintf(scratch, "%s@%s", action_string, devpath);
+-
+- /* copy keys to our continuous event payload buffer */
+- for (i = 0; i < env->envp_idx; i++) {
+- len = strlen(env->envp[i]) + 1;
+- scratch = skb_put(skb, len);
+- strcpy(scratch, env->envp[i]);
+- }
+-
+- NETLINK_CB(skb).dst_group = 1;
+- retval = netlink_broadcast_filtered(uevent_sock, skb,
+- 0, 1, GFP_KERNEL,
+- kobj_bcast_filter,
+- kobj);
+- /* ENOBUFS should be handled in userspace */
+- if (retval == -ENOBUFS || retval == -ESRCH)
+- retval = 0;
+- } else
+- retval = -ENOMEM;
+- }
+-#endif
++ retval = kobject_uevent_net_broadcast(kobj, env, action_string,
++ devpath);
+ mutex_unlock(&uevent_sock_mutex);
+
+ #ifdef CONFIG_UEVENT_HELPER
diff --git a/series.conf b/series.conf
index 32653d3da5..5622190827 100644
--- a/series.conf
+++ b/series.conf
@@ -8763,6 +8763,7 @@
patches.arch/s390-qeth-translate-SETVLAN-DELVLAN-errors.patch
patches.drivers/net-mvpp2-remove-useless-goto.patch
patches.fixes/bpf-Implement-map_delete_elem-for-BPF_MAP_TYPE_LPM_T.patch
+ patches.fixes/kobject-add-kobject_uevent_net_broadcast.patch
patches.drivers/cxgb4-add-new-T5-pci-device-id-s-34929cb4.patch
patches.drivers/drivers-net-e1000e-use-setup_timer-helper.patch
patches.drivers/drivers-net-bnxt-use-setup_timer-helper.patch