lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <1-1000-10527-1242938044-3360@rere.qmqm.pl>
Date:	Thu, 21 May 2009 22:34:04 +0200 (CEST)
From:	Michał Mirosław  
	<mirq-linux@...e.qmqm.pl>
To:	netdev@...r.kernel.org
Subject: [PATCH 1/6 2.6.30-rc6] genetlink: Introduce genl_register_family_with_ops()

This introduces genl_register_family_with_ops() that registers a genetlink
family along with operations from a table. This is used to kill copy'n'paste
occurrences in following patches.

Signed-off-by: Michał Mirosław <mirq-linux@...e.qmqm.pl>

diff -urN linux-orig-mqbr/include/net/genetlink.h linux-mqbr/include/net/genetlink.h
--- linux-orig-mqbr/include/net/genetlink.h	2009-03-24 00:12:14.000000000 +0100
+++ linux-mqbr/include/net/genetlink.h	2009-05-21 17:46:30.000000000 +0200
@@ -88,6 +88,8 @@
 };
 
 extern int genl_register_family(struct genl_family *family);
+extern int genl_register_family_with_ops(struct genl_family *family,
+	struct genl_ops *ops, size_t n_ops);
 extern int genl_unregister_family(struct genl_family *family);
 extern int genl_register_ops(struct genl_family *, struct genl_ops *ops);
 extern int genl_unregister_ops(struct genl_family *, struct genl_ops *ops);
diff -urN linux-orig-mqbr/net/netlink/genetlink.c linux-mqbr/net/netlink/genetlink.c
--- linux-orig-mqbr/net/netlink/genetlink.c	2009-03-24 00:12:14.000000000 +0100
+++ linux-mqbr/net/netlink/genetlink.c	2009-05-21 18:43:34.000000000 +0200
@@ -384,6 +384,52 @@
 }
 
 /**
+ * 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 err, i;
+
+	err = genl_register_family(family);
+	if (err)
+		return err;
+
+	for (i = 0; i < n_ops; ++i, ++ops) {
+		err = genl_register_ops(family, ops);
+		if (err)
+			goto err_out;
+	}
+	return 0;
+err_out:
+	genl_unregister_family(family);
+	return err;
+}
+EXPORT_SYMBOL(genl_register_family_with_ops);
+
+/**
  * genl_unregister_family - unregister generic netlink family
  * @family: generic netlink family
  *
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ