Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4fdb3bb7 authored by Harald Welte's avatar Harald Welte Committed by David S. Miller
Browse files

[NETLINK]: Add properly module refcounting for kernel netlink sockets.



- Remove bogus code for compiling netlink as module
- Add module refcounting support for modules implementing a netlink
  protocol
- Add support for autoloading modules that implement a netlink protocol
  as soon as someone opens a socket for that protocol

Signed-off-by: default avatarHarald Welte <laforge@netfilter.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 020b4c12
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -88,7 +88,7 @@ static struct w1_master * w1_alloc_dev(u32 id, int slave_count, int slave_ttl,

	dev->groups = 23;
	dev->seq = 1;
	dev->nls = netlink_kernel_create(NETLINK_W1, NULL);
	dev->nls = netlink_kernel_create(NETLINK_W1, NULL, THIS_MODULE);
	if (!dev->nls) {
		printk(KERN_ERR "Failed to create new netlink socket(%u) for w1 master %s.\n",
			NETLINK_NFLOG, dev->dev.bus_id);
@@ -225,3 +225,5 @@ void w1_remove_master_device(struct w1_bus_master *bm)

EXPORT_SYMBOL(w1_add_master_device);
EXPORT_SYMBOL(w1_remove_master_device);

MODULE_ALIAS_NET_PF_PROTO(PF_NETLINK, NETLINK_W1);
+3 −0
Original line number Diff line number Diff line
@@ -282,5 +282,8 @@ static struct proto_ops name##_ops = { \
#define MODULE_ALIAS_NETPROTO(proto) \
	MODULE_ALIAS("net-pf-" __stringify(proto))

#define MODULE_ALIAS_NET_PF_PROTO(pf, proto) \
	MODULE_ALIAS("net-pf-" __stringify(pf) "-proto-" __stringify(proto))

#endif /* __KERNEL__ */
#endif	/* _LINUX_NET_H */
+1 −1
Original line number Diff line number Diff line
@@ -117,7 +117,7 @@ struct netlink_skb_parms
#define NETLINK_CREDS(skb)	(&NETLINK_CB((skb)).creds)


extern struct sock *netlink_kernel_create(int unit, void (*input)(struct sock *sk, int len));
extern struct sock *netlink_kernel_create(int unit, void (*input)(struct sock *sk, int len), struct module *module);
extern void netlink_ack(struct sk_buff *in_skb, struct nlmsghdr *nlh, int err);
extern int netlink_unicast(struct sock *ssk, struct sk_buff *skb, __u32 pid, int nonblock);
extern int netlink_broadcast(struct sock *ssk, struct sk_buff *skb, __u32 pid,
+2 −1
Original line number Diff line number Diff line
@@ -514,7 +514,8 @@ static int __init audit_init(void)
{
	printk(KERN_INFO "audit: initializing netlink socket (%s)\n",
	       audit_default ? "enabled" : "disabled");
	audit_sock = netlink_kernel_create(NETLINK_AUDIT, audit_receive);
	audit_sock = netlink_kernel_create(NETLINK_AUDIT, audit_receive,
					   THIS_MODULE);
	if (!audit_sock)
		audit_panic("cannot initialize netlink socket");

+2 −1
Original line number Diff line number Diff line
@@ -153,7 +153,8 @@ EXPORT_SYMBOL_GPL(kobject_uevent_atomic);

static int __init kobject_uevent_init(void)
{
	uevent_sock = netlink_kernel_create(NETLINK_KOBJECT_UEVENT, NULL);
	uevent_sock = netlink_kernel_create(NETLINK_KOBJECT_UEVENT, NULL,
					    THIS_MODULE);

	if (!uevent_sock) {
		printk(KERN_ERR
Loading