[1/9] batman-adv: Add compat for genl_dump_check_consistent

Message ID 20181030210130.18152-2-sven@narfation.org (mailing list archive)
State Accepted, archived
Commit 5f1eed5f847d704173fda62c8703e5794398e073
Delegated to: Simon Wunderlich
Headers
Series batman-adv: Add inconsistent nl dump detection |

Commit Message

Sven Eckelmann Oct. 30, 2018, 9:01 p.m. UTC
  The commit 0a833c29d896 ("genetlink: fix genlmsg_nlhdr()") removed the
family parameter for genl_dump_check_consistent. It is actually not needed
because batman-adv doesn't use userspace headers and a dummy family with
hdrsize 0 can be used for these kernel versions.

Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
 compat-include/net/genetlink.h | 45 ++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)
 create mode 100644 compat-include/net/genetlink.h
  

Patch

diff --git a/compat-include/net/genetlink.h b/compat-include/net/genetlink.h
new file mode 100644
index 00000000..026500c3
--- /dev/null
+++ b/compat-include/net/genetlink.h
@@ -0,0 +1,45 @@ 
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (C) 2007-2018  B.A.T.M.A.N. contributors:
+ *
+ * Marek Lindner, Simon Wunderlich
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * This file contains macros for maintaining compatibility with older versions
+ * of the Linux kernel.
+ */
+
+#ifndef _NET_BATMAN_ADV_COMPAT_NET_GENETLINK_H_
+#define _NET_BATMAN_ADV_COMPAT_NET_GENETLINK_H_
+
+#include <linux/version.h>
+#include_next <net/genetlink.h>
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0)
+
+static inline
+void batadv_genl_dump_check_consistent(struct netlink_callback *cb,
+				       void *user_hdr)
+{
+	struct genl_family genl_family = {
+		.hdrsize = 0,
+	};
+
+	genl_dump_check_consistent(cb, user_hdr, &genl_family);
+}
+
+#define genl_dump_check_consistent batadv_genl_dump_check_consistent
+
+#endif /* < KERNEL_VERSION(4, 15, 0) */
+
+#endif /* _NET_BATMAN_ADV_COMPAT_NET_GENETLINK_H_ */