Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

netlink: hide struct module parameter in netlink_kernel_create

This patch defines netlink_kernel_create as a wrapper function of
__netlink_kernel_create to hide the struct module *me parameter
(which seems to be THIS_MODULE in all existing netlink subsystems).

Suggested by David S. Miller.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Pablo Neira Ayuso and committed by
David S. Miller
9f00d977 9785e10a

+31 -37
+1 -2
crypto/crypto_user.c
··· 500 500 .input = crypto_netlink_rcv, 501 501 }; 502 502 503 - crypto_nlsk = netlink_kernel_create(&init_net, NETLINK_CRYPTO, 504 - THIS_MODULE, &cfg); 503 + crypto_nlsk = netlink_kernel_create(&init_net, NETLINK_CRYPTO, &cfg); 505 504 if (!crypto_nlsk) 506 505 return -ENOMEM; 507 506
+1 -2
drivers/connector/connector.c
··· 264 264 .input = dev->input, 265 265 }; 266 266 267 - dev->nls = netlink_kernel_create(&init_net, NETLINK_CONNECTOR, 268 - THIS_MODULE, &cfg); 267 + dev->nls = netlink_kernel_create(&init_net, NETLINK_CONNECTOR, &cfg); 269 268 if (!dev->nls) 270 269 return -EIO; 271 270
+1 -1
drivers/infiniband/core/netlink.c
··· 177 177 .input = ibnl_rcv, 178 178 }; 179 179 180 - nls = netlink_kernel_create(&init_net, NETLINK_RDMA, THIS_MODULE, &cfg); 180 + nls = netlink_kernel_create(&init_net, NETLINK_RDMA, &cfg); 181 181 if (!nls) { 182 182 pr_warn("Failed to create netlink socket\n"); 183 183 return -ENOMEM;
+1 -1
drivers/scsi/scsi_netlink.c
··· 501 501 } 502 502 503 503 scsi_nl_sock = netlink_kernel_create(&init_net, NETLINK_SCSITRANSPORT, 504 - THIS_MODULE, &cfg); 504 + &cfg); 505 505 if (!scsi_nl_sock) { 506 506 printk(KERN_ERR "%s: register of receive handler failed\n", 507 507 __func__);
+1 -2
drivers/scsi/scsi_transport_iscsi.c
··· 2969 2969 if (err) 2970 2970 goto unregister_conn_class; 2971 2971 2972 - nls = netlink_kernel_create(&init_net, NETLINK_ISCSI, 2973 - THIS_MODULE, &cfg); 2972 + nls = netlink_kernel_create(&init_net, NETLINK_ISCSI, &cfg); 2974 2973 if (!nls) { 2975 2974 err = -ENOBUFS; 2976 2975 goto unregister_session_class;
+10 -3
include/linux/netlink.h
··· 153 153 154 154 #include <linux/capability.h> 155 155 #include <linux/skbuff.h> 156 + #include <linux/module.h> 156 157 #include <net/scm.h> 157 158 158 159 struct net; ··· 189 188 unsigned int flags; 190 189 }; 191 190 192 - extern struct sock *netlink_kernel_create(struct net *net, int unit, 193 - struct module *module, 194 - struct netlink_kernel_cfg *cfg); 191 + extern struct sock *__netlink_kernel_create(struct net *net, int unit, 192 + struct module *module, 193 + struct netlink_kernel_cfg *cfg); 194 + static inline struct sock * 195 + netlink_kernel_create(struct net *net, int unit, struct netlink_kernel_cfg *cfg) 196 + { 197 + return __netlink_kernel_create(net, unit, THIS_MODULE, cfg); 198 + } 199 + 195 200 extern void netlink_kernel_release(struct sock *sk); 196 201 extern int __netlink_change_ngroups(struct sock *sk, unsigned int groups); 197 202 extern int netlink_change_ngroups(struct sock *sk, unsigned int groups);
+1 -2
kernel/audit.c
··· 971 971 972 972 printk(KERN_INFO "audit: initializing netlink socket (%s)\n", 973 973 audit_default ? "enabled" : "disabled"); 974 - audit_sock = netlink_kernel_create(&init_net, NETLINK_AUDIT, 975 - THIS_MODULE, &cfg); 974 + audit_sock = netlink_kernel_create(&init_net, NETLINK_AUDIT, &cfg); 976 975 if (!audit_sock) 977 976 audit_panic("cannot initialize netlink socket"); 978 977 else
+1 -2
lib/kobject_uevent.c
··· 382 382 if (!ue_sk) 383 383 return -ENOMEM; 384 384 385 - ue_sk->sk = netlink_kernel_create(net, NETLINK_KOBJECT_UEVENT, 386 - THIS_MODULE, &cfg); 385 + ue_sk->sk = netlink_kernel_create(net, NETLINK_KOBJECT_UEVENT, &cfg); 387 386 if (!ue_sk->sk) { 388 387 printk(KERN_ERR 389 388 "kobject_uevent: unable to create netlink socket!\n");
+1 -2
net/bridge/netfilter/ebt_ulog.c
··· 298 298 spin_lock_init(&ulog_buffers[i].lock); 299 299 } 300 300 301 - ebtulognl = netlink_kernel_create(&init_net, NETLINK_NFLOG, 302 - THIS_MODULE, &cfg); 301 + ebtulognl = netlink_kernel_create(&init_net, NETLINK_NFLOG, &cfg); 303 302 if (!ebtulognl) 304 303 ret = -ENOMEM; 305 304 else if ((ret = xt_register_target(&ebt_ulog_tg_reg)) != 0)
+1 -1
net/core/rtnetlink.c
··· 2384 2384 .flags = NL_CFG_F_NONROOT_RECV, 2385 2385 }; 2386 2386 2387 - sk = netlink_kernel_create(net, NETLINK_ROUTE, THIS_MODULE, &cfg); 2387 + sk = netlink_kernel_create(net, NETLINK_ROUTE, &cfg); 2388 2388 if (!sk) 2389 2389 return -ENOMEM; 2390 2390 net->rtnl = sk;
+1 -2
net/core/sock_diag.c
··· 172 172 .input = sock_diag_rcv, 173 173 }; 174 174 175 - net->diag_nlsk = netlink_kernel_create(net, NETLINK_SOCK_DIAG, 176 - THIS_MODULE, &cfg); 175 + net->diag_nlsk = netlink_kernel_create(net, NETLINK_SOCK_DIAG, &cfg); 177 176 return net->diag_nlsk == NULL ? -ENOMEM : 0; 178 177 } 179 178
+1 -2
net/decnet/netfilter/dn_rtmsg.c
··· 130 130 .input = dnrmg_receive_user_skb, 131 131 }; 132 132 133 - dnrmg = netlink_kernel_create(&init_net, 134 - NETLINK_DNRTMSG, THIS_MODULE, &cfg); 133 + dnrmg = netlink_kernel_create(&init_net, NETLINK_DNRTMSG, &cfg); 135 134 if (dnrmg == NULL) { 136 135 printk(KERN_ERR "dn_rtmsg: Cannot create netlink socket"); 137 136 return -ENOMEM;
+1 -1
net/ipv4/fib_frontend.c
··· 986 986 .input = nl_fib_input, 987 987 }; 988 988 989 - sk = netlink_kernel_create(net, NETLINK_FIB_LOOKUP, THIS_MODULE, &cfg); 989 + sk = netlink_kernel_create(net, NETLINK_FIB_LOOKUP, &cfg); 990 990 if (sk == NULL) 991 991 return -EAFNOSUPPORT; 992 992 net->ipv4.fibnl = sk;
+1 -2
net/ipv4/netfilter/ipt_ULOG.c
··· 396 396 for (i = 0; i < ULOG_MAXNLGROUPS; i++) 397 397 setup_timer(&ulog_buffers[i].timer, ulog_timer, i); 398 398 399 - nflognl = netlink_kernel_create(&init_net, NETLINK_NFLOG, 400 - THIS_MODULE, &cfg); 399 + nflognl = netlink_kernel_create(&init_net, NETLINK_NFLOG, &cfg); 401 400 if (!nflognl) 402 401 return -ENOMEM; 403 402
+1 -1
net/netfilter/nfnetlink.c
··· 241 241 #endif 242 242 }; 243 243 244 - nfnl = netlink_kernel_create(net, NETLINK_NETFILTER, THIS_MODULE, &cfg); 244 + nfnl = netlink_kernel_create(net, NETLINK_NETFILTER, &cfg); 245 245 if (!nfnl) 246 246 return -ENOMEM; 247 247 net->nfnl_stash = nfnl;
+3 -5
net/netlink/af_netlink.c
··· 1526 1526 */ 1527 1527 1528 1528 struct sock * 1529 - netlink_kernel_create(struct net *net, int unit, 1530 - struct module *module, 1531 - struct netlink_kernel_cfg *cfg) 1529 + __netlink_kernel_create(struct net *net, int unit, struct module *module, 1530 + struct netlink_kernel_cfg *cfg) 1532 1531 { 1533 1532 struct socket *sock; 1534 1533 struct sock *sk; ··· 1602 1603 sock_release(sock); 1603 1604 return NULL; 1604 1605 } 1605 - EXPORT_SYMBOL(netlink_kernel_create); 1606 - 1606 + EXPORT_SYMBOL(__netlink_kernel_create); 1607 1607 1608 1608 void 1609 1609 netlink_kernel_release(struct sock *sk)
+1 -2
net/netlink/genetlink.c
··· 922 922 }; 923 923 924 924 /* we'll bump the group number right afterwards */ 925 - net->genl_sock = netlink_kernel_create(net, NETLINK_GENERIC, 926 - THIS_MODULE, &cfg); 925 + net->genl_sock = netlink_kernel_create(net, NETLINK_GENERIC, &cfg); 927 926 928 927 if (!net->genl_sock && net_eq(net, &init_net)) 929 928 panic("GENL: Cannot initialize generic netlink\n");
+1 -1
net/xfrm/xfrm_user.c
··· 2963 2963 .input = xfrm_netlink_rcv, 2964 2964 }; 2965 2965 2966 - nlsk = netlink_kernel_create(net, NETLINK_XFRM, THIS_MODULE, &cfg); 2966 + nlsk = netlink_kernel_create(net, NETLINK_XFRM, &cfg); 2967 2967 if (nlsk == NULL) 2968 2968 return -ENOMEM; 2969 2969 net->xfrm.nlsk_stash = nlsk; /* Don't set to NULL */
+1 -2
security/selinux/netlink.c
··· 116 116 .flags = NL_CFG_F_NONROOT_RECV, 117 117 }; 118 118 119 - selnl = netlink_kernel_create(&init_net, NETLINK_SELINUX, 120 - THIS_MODULE, &cfg); 119 + selnl = netlink_kernel_create(&init_net, NETLINK_SELINUX, &cfg); 121 120 if (selnl == NULL) 122 121 panic("SELinux: Cannot create netlink socket."); 123 122 return 0;