The two implementations have almost identical structures - vif_device and
mif_device. As a step toward uniforming the mr_tables, eliminate the
mif_device and relocate the vif_device definition into a new common
header file.
Also, introduce a common initializing function for setting most of the
vif_device fields in a new common source file. This requires modifying
the ipv{4,6] Kconfig and ipv4 makefile as we're introducing a new common
config option - CONFIG_IP_MROUTE_COMMON.
Signed-off-by: Yuval Mintz
---
include/linux/mroute.h | 13 +---
include/linux/mroute6.h | 11 +-
include/linux/mroute_base.h | 52 +
net/ipv4/Kconfig| 5 +
net/ipv4/Makefile | 1 +
net/ipv4/ipmr.c | 32 +---
net/ipv4/ipmr_base.c| 28
net/ipv6/Kconfig| 1 +
net/ipv6/ip6mr.c| 37
9 files changed, 117 insertions(+), 63 deletions(-)
create mode 100644 include/linux/mroute_base.h
create mode 100644 net/ipv4/ipmr_base.c
diff --git a/include/linux/mroute.h b/include/linux/mroute.h
index 5396521..b8aadff 100644
--- a/include/linux/mroute.h
+++ b/include/linux/mroute.h
@@ -9,6 +9,7 @@
#include
#include
#include
+#include
#ifdef CONFIG_IP_MROUTE
static inline int ip_mroute_opt(int opt)
@@ -56,18 +57,6 @@ static inline bool ipmr_rule_default(const struct fib_rule
*rule)
}
#endif
-struct vif_device {
- struct net_device *dev; /* Device we are using
*/
- struct netdev_phys_item_id dev_parent_id; /* Device parent ID
*/
- unsigned long bytes_in,bytes_out;
- unsigned long pkt_in,pkt_out; /* Statistics
*/
- unsigned long rate_limit; /* Traffic shaping (NI)
*/
- unsigned char threshold; /* TTL threshold
*/
- unsigned short flags; /* Control flags
*/
- __be32 local,remote; /* Addresses(remote for
tunnels)*/
- int link; /* Physical interface index
*/
-};
-
struct vif_entry_notifier_info {
struct fib_notifier_info info;
struct net_device *dev;
diff --git a/include/linux/mroute6.h b/include/linux/mroute6.h
index 3014c52..e5e5b82 100644
--- a/include/linux/mroute6.h
+++ b/include/linux/mroute6.h
@@ -7,6 +7,7 @@
#include /* for struct sk_buff_head */
#include
#include
+#include
#ifdef CONFIG_IPV6_MROUTE
static inline int ip6_mroute_opt(int opt)
@@ -62,16 +63,6 @@ static inline void ip6_mr_cleanup(void)
}
#endif
-struct mif_device {
- struct net_device *dev; /* Device we are using
*/
- unsigned long bytes_in,bytes_out;
- unsigned long pkt_in,pkt_out; /* Statistics
*/
- unsigned long rate_limit; /* Traffic shaping (NI)
*/
- unsigned char threshold; /* TTL threshold
*/
- unsigned short flags; /* Control flags
*/
- int link; /* Physical interface index
*/
-};
-
#define VIFF_STATIC 0x8000
struct mfc6_cache {
diff --git a/include/linux/mroute_base.h b/include/linux/mroute_base.h
new file mode 100644
index 000..0de651e
--- /dev/null
+++ b/include/linux/mroute_base.h
@@ -0,0 +1,52 @@
+#ifndef __LINUX_MROUTE_BASE_H
+#define __LINUX_MROUTE_BASE_H
+
+#include
+
+/**
+ * struct vif_device - interface representor for multicast routing
+ * @dev: network device being used
+ * @bytes_in: statistic; bytes ingressing
+ * @bytes_out: statistic; bytes egresing
+ * @pkt_in: statistic; packets ingressing
+ * @pkt_out: statistic; packets egressing
+ * @rate_limit: Traffic shaping (NI)
+ * @threshold: TTL threshold
+ * @flags: Control flags
+ * @link: Physical interface index
+ * @dev_parent_id: device parent id
+ * @local: Local address
+ * @remote: Remote address for tunnels
+ */
+struct vif_device {
+ struct net_device *dev;
+ unsigned long bytes_in, bytes_out;
+ unsigned long pkt_in, pkt_out;
+ unsigned long rate_limit;
+ unsigned char threshold;
+ unsigned short flags;
+ int link;
+
+ /* Currently only used by ipmr */
+ struct netdev_phys_item_id dev_parent_id;
+ __be32 local, remote;
+};
+
+#ifdef CONFIG_IP_MROUTE_COMMON
+void vif_device_init(struct vif_device *v,
+struct net_device *dev,
+unsigned long rate_limit,
+unsigned char threshold,
+unsigned short flags,
+unsigned short get_iflink_mask);
+#else
+static inline void vif_device_init(struct vif_device *v,
+ struct net_device *dev,
+ unsi