File: genetlink-openvswitch.c

package info (click to toggle)
openvswitch 2.3.0%2Bgit20140819-3
  • links: PTS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 24,156 kB
  • sloc: sh: 223,720; ansic: 153,459; python: 13,272; xml: 12,432; perl: 408; makefile: 382
file content (55 lines) | stat: -rw-r--r-- 1,372 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <net/genetlink.h>
#include <linux/version.h>

#if LINUX_VERSION_CODE < KERNEL_VERSION(3,13,0)

#undef genl_notify

void rpl_genl_notify(struct rpl_genl_family *family, struct sk_buff *skb,
		     struct net *net, u32 portid, u32 group,
		     struct nlmsghdr *nlh, gfp_t flags)
{
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0)
	struct sock *sk = net->genl_sock;
	int report = 0;

	if (nlh)
		report = nlmsg_report(nlh);

	nlmsg_notify(sk, skb, portid, group, report, flags);
#else
	genl_notify(skb, net, portid, group, nlh, flags);
#endif
}

int rpl___genl_register_family(struct rpl_genl_family *f)
{
	int err;

	f->compat_family.id = f->id;
	f->compat_family.hdrsize = f->hdrsize;
	strncpy(f->compat_family.name, f->name, GENL_NAMSIZ);
	f->compat_family.version = f->version;
	f->compat_family.maxattr = f->maxattr;
	f->compat_family.netnsok = f->netnsok;
#ifdef HAVE_PARALLEL_OPS
	f->compat_family.parallel_ops = f->parallel_ops;
#endif
	err = genl_register_family_with_ops(&f->compat_family,
					    (struct genl_ops *) f->ops, f->n_ops);
	if (err)
		goto error;

	if (f->mcgrps) {
		/* Need to Fix GROUP_ID() for more than one group. */
		BUG_ON(f->n_mcgrps > 1);
		err = genl_register_mc_group(&f->compat_family,
					     (struct genl_multicast_group *) f->mcgrps);
		if (err)
			goto error;
	}
error:
	return err;

}
#endif /* kernel version < 3.13.0 */