X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=datapath%2Flinux%2Fcompat%2Fgenetlink-openvswitch.c;h=08f0fab8b0f1a43defc444ec6b90e06f74d43787;hb=c5cf10598f8c9f4428291e9df3ecd72a05fb1ccf;hp=810223b3d428a9a4a3c1c5054e10f2ee9c2209b6;hpb=5ca1ba484bd9ade5116a49cf241cb98219d7d696;p=sliver-openvswitch.git diff --git a/datapath/linux/compat/genetlink-openvswitch.c b/datapath/linux/compat/genetlink-openvswitch.c index 810223b3d..08f0fab8b 100644 --- a/datapath/linux/compat/genetlink-openvswitch.c +++ b/datapath/linux/compat/genetlink-openvswitch.c @@ -1,149 +1,55 @@ #include #include -#define GENL_FIRST_MCGROUP 16 -#define GENL_LAST_MCGROUP 31 +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,13,0) -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23) -#include -#include +#undef genl_notify -#include "openvswitch/datapath-compat.h" - -static DEFINE_MUTEX(mc_group_mutex); - -int genl_register_mc_group(struct genl_family *family, - struct genl_multicast_group *grp) +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) { - static int next_group = GENL_FIRST_MCGROUP; - - grp->family = family; - - if (!strcmp(grp->name, OVS_VPORT_MCGROUP)) { - grp->id = OVS_VPORT_MCGROUP_FALLBACK_ID; - return 0; - } - - mutex_lock(&mc_group_mutex); - grp->id = next_group; +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0) + struct sock *sk = net->genl_sock; + int report = 0; - if (++next_group > GENL_LAST_MCGROUP) - next_group = GENL_FIRST_MCGROUP; - mutex_unlock(&mc_group_mutex); + if (nlh) + report = nlmsg_report(nlh); - return 0; + nlmsg_notify(sk, skb, portid, group, report, flags); +#else + genl_notify(skb, net, portid, group, nlh, flags); +#endif } -#endif /* kernel < 2.6.23 */ -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31) -/** - * genl_register_family_with_ops - register a generic netlink family - * @family: generic netlink family - * @ops: operations to be registered - * @n_ops: number of elements to register - * - * Registers the specified family and operations from the specified table. - * Only one family may be registered with the same family name or identifier. - * - * The family id may equal GENL_ID_GENERATE causing an unique id to - * be automatically generated and assigned. - * - * Either a doit or dumpit callback must be specified for every registered - * operation or the function will fail. Only one operation structure per - * command identifier may be registered. - * - * See include/net/genetlink.h for more documenation on the operations - * structure. - * - * This is equivalent to calling genl_register_family() followed by - * genl_register_ops() for every operation entry in the table taking - * care to unregister the family on error path. - * - * Return 0 on success or a negative error code. - */ -int genl_register_family_with_ops(struct genl_family *family, - struct genl_ops *ops, size_t n_ops) +int rpl___genl_register_family(struct rpl_genl_family *f) { - int err, i; - - err = genl_register_family(family); + 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) - return err; + goto error; - for (i = 0; i < n_ops; ++i, ++ops) { - err = genl_register_ops(family, ops); + 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 err_out; - } - return 0; -err_out: - genl_unregister_family(family); - return err; -} -#endif - -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) -/** - * nlmsg_notify - send a notification netlink message - * @sk: netlink socket to use - * @skb: notification message - * @portid: destination netlink portid for reports or 0 - * @group: destination multicast group or 0 - * @report: 1 to report back, 0 to disable - * @flags: allocation flags - */ -int nlmsg_notify(struct sock *sk, struct sk_buff *skb, u32 portid, - unsigned int group, int report, gfp_t flags) -{ - int err = 0; - - if (group) { - int exclude_portid = 0; - - if (report) { - atomic_inc(&skb->users); - exclude_portid = portid; - } - - /* errors reported via destination sk->sk_err, but propagate - * delivery errors if NETLINK_BROADCAST_ERROR flag is set */ - err = nlmsg_multicast(sk, skb, exclude_portid, group, flags); - } - - if (report) { - int err2; - - err2 = nlmsg_unicast(sk, skb, portid); - if (!err || err == -ESRCH) - err = err2; + goto error; } - +error: return err; -} -#endif - -/* This is analogous to rtnl_notify() but uses genl_sock instead of rtnl. - * - * This is not (yet) in any upstream kernel. */ -void genl_notify(struct sk_buff *skb, struct net *net, u32 portid, u32 group, - struct nlmsghdr *nlh, gfp_t flags) -{ -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32) - struct sock *sk = net->genl_sock; -#else - struct sock *sk = genl_sock; -#endif - int report = 0; - - if (nlh) - report = nlmsg_report(nlh); - nlmsg_notify(sk, skb, portid, group, report, flags); } - -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30) -/* This function wasn't exported before 2.6.30. Lose! */ -void netlink_set_err(struct sock *ssk, u32 portid, u32 group, int code) -{ -} -#endif +#endif /* kernel version < 3.13.0 */