Skip to contentSkip to conversation

net: ipmr: more cleanups and mfc netlink support

PATCH In review Nikolay Aleksandrov 4 participants 11 messages Nov 26, 2015 – Nov 30, 2015

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover net: ipmr: more cleanups and mfc netlink support

From: Nikolay Aleksandrov <[email protected]>

Hi,
This set continues with the minor cleanups in the first 6 patches and patch 7 adds the first new feature - MFC manipulation via netlink. It registers NEWROUTE/DELROUTE for that purpose and uses the same semantics as the already present netlink dump. The only new attribute that is used is RTA_PREFSRC to denote an MFC_PROXY entry. Currently the table must exist before adding an entry, and new tables can be created only via setsockopt, but that will be changed in the future.
This set was tested with modified iproute2 which supports NEWROUTE/DELROUTE for RTNL_FAMILY_IPMR.

Cheers,
Nik

Nikolay Aleksandrov (7):
net: remove unnecessary mroute.h includes
net: ipmr: remove unused MFC_NOTIFY flag and make the flags enum
net: ipmr: adjust mroute.h style and drop extern
net: ipmr: move struct mr_table and VIF_EXISTS to mroute.h
net: ipmr: move pimsm_enabled to pim.h and rename
net: ipmr: fix setsockopt error return
net: ipmr: add mfc newroute/delroute netlink support

 include/linux/mroute.h    |  76 ++++++++++++---------
 include/linux/pim.h       |   5 ++
 net/ipv4/ip_gre.c         |   1 -
 net/ipv4/ip_output.c      |   1 -
 net/ipv4/ip_tunnel.c      |   1 -
 net/ipv4/ip_tunnel_core.c |   1 -
 net/ipv4/ip_vti.c         |   1 -
 net/ipv4/ipip.c           |   1 -
 net/ipv4/ipmr.c           | 168 +++++++++++++++++++++++++++++++++++++---------
 net/ipv6/ip6_gre.c        |   1 -
 10 files changed, 188 insertions(+), 68 deletions(-)
Signature · 1 line
2.4.3
#1 lore raw

PATCH 1/7 net: remove unnecessary mroute.h includes

From: Nikolay Aleksandrov <[email protected]>

It looks like many files are including mroute.h unnecessarily, so remove the include. Most importantly remove it from ipv6.

CC Hideaki YOSHIFUJI <[email protected]>
CC Steffen Klassert <[email protected]>
CC Herbert Xu <[email protected]>
---
 net/ipv4/ip_gre.c         | 1 -
 net/ipv4/ip_output.c      | 1 -
 net/ipv4/ip_tunnel.c      | 1 -
 net/ipv4/ip_tunnel_core.c | 1 -
 net/ipv4/ip_vti.c         | 1 -
 net/ipv4/ipip.c           | 1 -
 net/ipv6/ip6_gre.c        | 1 -
 7 files changed, 7 deletions(-)
net/ipv4/ip_gre.c +0 -1
index 614521437e30..04a48c0159cc 100644
@@ -24,7 +24,6 @@
 #include <linux/tcp.h>
 #include <linux/udp.h>
 #include <linux/if_arp.h>
-#include <linux/mroute.h>
 #include <linux/if_vlan.h>
 #include <linux/init.h>
 #include <linux/in6.h>
net/ipv4/ip_output.c +0 -1
index 4233cbe47052..e0b94cd843d7 100644
@@ -76,7 +76,6 @@
 #include <linux/igmp.h>
 #include <linux/netfilter_ipv4.h>
 #include <linux/netfilter_bridge.h>
-#include <linux/mroute.h>
 #include <linux/netlink.h>
 #include <linux/tcp.h>
 
net/ipv4/ip_tunnel.c +0 -1
index cbb51f3fac06..0f6e9ee031c4 100644
@@ -30,7 +30,6 @@
 #include <linux/tcp.h>
 #include <linux/udp.h>
 #include <linux/if_arp.h>
-#include <linux/mroute.h>
 #include <linux/init.h>
 #include <linux/in6.h>
 #include <linux/inetdevice.h>
net/ipv4/ip_tunnel_core.c +0 -1
index 6cb9009c3d96..1db8418aa62e 100644
@@ -24,7 +24,6 @@
 #include <linux/netdevice.h>
 #include <linux/in.h>
 #include <linux/if_arp.h>
-#include <linux/mroute.h>
 #include <linux/init.h>
 #include <linux/in6.h>
 #include <linux/inetdevice.h>
net/ipv4/ip_vti.c +0 -1
index 4d8f0b698777..02d9c21e2953 100644
@@ -30,7 +30,6 @@
 #include <linux/tcp.h>
 #include <linux/udp.h>
 #include <linux/if_arp.h>
-#include <linux/mroute.h>
 #include <linux/init.h>
 #include <linux/netfilter_ipv4.h>
 #include <linux/if_ether.h>
net/ipv4/ipip.c +0 -1
index f34c31defafe..1f067294cbc5 100644
@@ -103,7 +103,6 @@
 #include <linux/tcp.h>
 #include <linux/udp.h>
 #include <linux/if_arp.h>
-#include <linux/mroute.h>
 #include <linux/init.h>
 #include <linux/netfilter_ipv4.h>
 #include <linux/if_ether.h>
net/ipv6/ip6_gre.c +0 -1
index 3c7b9310b33f..938d03ce5e4b 100644
@@ -24,7 +24,6 @@
 #include <linux/tcp.h>
 #include <linux/udp.h>
 #include <linux/if_arp.h>
-#include <linux/mroute.h>
 #include <linux/init.h>
 #include <linux/in6.h>
 #include <linux/inetdevice.h>
Signature · 1 line
2.4.3
#2 lore raw

PATCH 2/7 net: ipmr: remove unused MFC_NOTIFY flag and make the flags enum

In reply to Nikolay Aleksandrov

From: Nikolay Aleksandrov <[email protected]>

MFC_NOTIFY was introduced in kernel 2.1.68 but afaik it hasn't been used and I couldn't find any users currently so just remove it. Only MFC_STATIC is left, so move it into an enum, add a description and use BIT().

---
 include/linux/mroute.h | 10 +++++++---
 net/ipv4/ipmr.c        |  2 --
 2 files changed, 7 insertions(+), 5 deletions(-)
include/linux/mroute.h +7 -3
index 79aaa9fc1a15..fa66ebc1fed6 100644
@@ -64,6 +64,13 @@ struct vif_device {
 
 #define VIFF_STATIC 0x8000
 
+/* mfc_flags:
+ * MFC_STATIC - the entry was added statically (not by a routing daemon)
+ */
+enum {
+	MFC_STATIC = BIT(0),
+};
+
 struct mfc_cache {
 	struct list_head list;
 	__be32 mfc_mcastgrp;			/* Group the entry belongs to 	*/
@@ -89,9 +96,6 @@ struct mfc_cache {
 	struct rcu_head	rcu;
 };
 
-#define MFC_STATIC		1
-#define MFC_NOTIFY		2
-
 #define MFC_LINES		64
 
 #ifdef __BIG_ENDIAN
net/ipv4/ipmr.c +0 -2
index a2d248d9c35c..a74e61883b8f 100644
@@ -2199,8 +2199,6 @@ int ipmr_get_route(struct net *net, struct sk_buff *skb,
 	}
 
 	read_lock(&mrt_lock);
-	if (!nowait && (rtm->rtm_flags & RTM_F_NOTIFY))
-		cache->mfc_flags |= MFC_NOTIFY;
 	err = __ipmr_fill_mroute(mrt, skb, cache, rtm);
 	read_unlock(&mrt_lock);
 	rcu_read_unlock();
Signature · 1 line
2.4.3
#3 lore raw

PATCH 3/7 net: ipmr: adjust mroute.h style and drop extern

In reply to Nikolay Aleksandrov

From: Nikolay Aleksandrov <[email protected]>

Remove extra spaces and tabs, adjust function definitions, remove an unnecessary ifdef (already used below, just move code) and drop extern from the functions.

---
 include/linux/mroute.h | 47 +++++++++++++++++++++--------------------------
 1 file changed, 21 insertions(+), 26 deletions(-)
include/linux/mroute.h +21 -26
index fa66ebc1fed6..7c567a2679ce 100644
@@ -9,38 +9,28 @@
 #ifdef CONFIG_IP_MROUTE
 static inline int ip_mroute_opt(int opt)
 {
-	return (opt >= MRT_BASE) && (opt <= MRT_MAX);
+	return opt >= MRT_BASE && opt <= MRT_MAX;
 }
-#else
-static inline int ip_mroute_opt(int opt)
-{
-	return 0;
-}
-#endif
 
-#ifdef CONFIG_IP_MROUTE
-extern int ip_mroute_setsockopt(struct sock *, int, char __user *, unsigned int);
-extern int ip_mroute_getsockopt(struct sock *, int, char __user *, int __user *);
-extern int ipmr_ioctl(struct sock *sk, int cmd, void __user *arg);
-extern int ipmr_compat_ioctl(struct sock *sk, unsigned int cmd, void __user *arg);
-extern int ip_mr_init(void);
+int ip_mroute_setsockopt(struct sock *, int, char __user *, unsigned int);
+int ip_mroute_getsockopt(struct sock *, int, char __user *, int __user *);
+int ipmr_ioctl(struct sock *sk, int cmd, void __user *arg);
+int ipmr_compat_ioctl(struct sock *sk, unsigned int cmd, void __user *arg);
+int ip_mr_init(void);
 #else
-static inline
-int ip_mroute_setsockopt(struct sock *sock,
-			 int optname, char __user *optval, unsigned int optlen)
+static inline int ip_mroute_setsockopt(struct sock *sock, int optname,
+				       char __user *optval, unsigned int optlen)
 {
 	return -ENOPROTOOPT;
 }
 
-static inline
-int ip_mroute_getsockopt(struct sock *sock,
-			 int optname, char __user *optval, int __user *optlen)
+static inline int ip_mroute_getsockopt(struct sock *sock, int optname,
+				       char __user *optval, int __user *optlen)
 {
 	return -ENOPROTOOPT;
 }
 
-static inline
-int ipmr_ioctl(struct sock *sk, int cmd, void __user *arg)
+static inline int ipmr_ioctl(struct sock *sk, int cmd, void __user *arg)
 {
 	return -ENOIOCTLCMD;
 }
@@ -49,6 +39,11 @@ static inline int ip_mr_init(void)
 {
 	return 0;
 }
+
+static inline int ip_mroute_opt(int opt)
+{
+	return 0;
+}
 #endif
 
 struct vif_device {
@@ -96,16 +91,16 @@ struct mfc_cache {
 	struct rcu_head	rcu;
 };
 
-#define MFC_LINES		64
+#define MFC_LINES 64
 
 #ifdef __BIG_ENDIAN
 #define MFC_HASH(a,b)	(((((__force u32)(__be32)a)>>24)^(((__force u32)(__be32)b)>>26))&(MFC_LINES-1))
 #else
 #define MFC_HASH(a,b)	((((__force u32)(__be32)a)^(((__force u32)(__be32)b)>>2))&(MFC_LINES-1))
-#endif		
+#endif
 
 struct rtmsg;
-extern int ipmr_get_route(struct net *net, struct sk_buff *skb,
-			  __be32 saddr, __be32 daddr,
-			  struct rtmsg *rtm, int nowait);
+int ipmr_get_route(struct net *net, struct sk_buff *skb,
+		   __be32 saddr, __be32 daddr,
+		   struct rtmsg *rtm, int nowait);
 #endif
Signature · 1 line
2.4.3
#4 lore raw

PATCH 4/7 net: ipmr: move struct mr_table and VIF_EXISTS to mroute.h

In reply to Nikolay Aleksandrov

From: Nikolay Aleksandrov <[email protected]>

Move the definitions of VIF_EXISTS() and struct mr_table to mroute.h

---
 include/linux/mroute.h | 21 +++++++++++++++++++--
 net/ipv4/ipmr.c        | 18 ------------------
 2 files changed, 19 insertions(+), 20 deletions(-)
include/linux/mroute.h +19 -2
index 7c567a2679ce..bf9b322cb0b0 100644
@@ -59,6 +59,25 @@ struct vif_device {
 
 #define VIFF_STATIC 0x8000
 
+#define VIF_EXISTS(_mrt, _idx) ((_mrt)->vif_table[_idx].dev != NULL)
+#define MFC_LINES 64
+
+struct mr_table {
+	struct list_head	list;
+	possible_net_t		net;
+	u32			id;
+	struct sock __rcu	*mroute_sk;
+	struct timer_list	ipmr_expire_timer;
+	struct list_head	mfc_unres_queue;
+	struct list_head	mfc_cache_array[MFC_LINES];
+	struct vif_device	vif_table[MAXVIFS];
+	int			maxvif;
+	atomic_t		cache_resolve_queue_len;
+	bool			mroute_do_assert;
+	bool			mroute_do_pim;
+	int			mroute_reg_vif_num;
+};
+
 /* mfc_flags:
  * MFC_STATIC - the entry was added statically (not by a routing daemon)
  */
@@ -91,8 +110,6 @@ struct mfc_cache {
 	struct rcu_head	rcu;
 };
 
-#define MFC_LINES 64
-
 #ifdef __BIG_ENDIAN
 #define MFC_HASH(a,b)	(((((__force u32)(__be32)a)>>24)^(((__force u32)(__be32)b)>>26))&(MFC_LINES-1))
 #else
net/ipv4/ipmr.c +0 -18
index a74e61883b8f..ff3dbbb9f11c 100644
@@ -67,22 +67,6 @@
 #include <net/fib_rules.h>
 #include <linux/netconf.h>
 
-struct mr_table {
-	struct list_head	list;
-	possible_net_t		net;
-	u32			id;
-	struct sock __rcu	*mroute_sk;
-	struct timer_list	ipmr_expire_timer;
-	struct list_head	mfc_unres_queue;
-	struct list_head	mfc_cache_array[MFC_LINES];
-	struct vif_device	vif_table[MAXVIFS];
-	int			maxvif;
-	atomic_t		cache_resolve_queue_len;
-	bool			mroute_do_assert;
-	bool			mroute_do_pim;
-	int			mroute_reg_vif_num;
-};
-
 struct ipmr_rule {
 	struct fib_rule		common;
 };
@@ -104,8 +88,6 @@ static DEFINE_RWLOCK(mrt_lock);
 
 /* Multicast router control variables */
 
-#define VIF_EXISTS(_mrt, _idx) ((_mrt)->vif_table[_idx].dev != NULL)
-
 /* Special spinlock for queue of unresolved entries */
 static DEFINE_SPINLOCK(mfc_unres_lock);
 
Signature · 1 line
2.4.3
#5 lore raw

PATCH 5/7 net: ipmr: move pimsm_enabled to pim.h and rename

In reply to Nikolay Aleksandrov

From: Nikolay Aleksandrov <[email protected]>

Move the inline pimsm_enabled() to pim.h and rename it to ipmr_pimsm_enabled to show it's for the ipv4 ipmr code since pim.h is used by IPv6 too.

---
 include/linux/pim.h |  5 +++++
 net/ipv4/ipmr.c     | 11 +++--------
 2 files changed, 8 insertions(+), 8 deletions(-)
include/linux/pim.h +5 -0
index 252bf6644c51..e1d756f81348 100644
@@ -13,6 +13,11 @@
 
 #define PIM_NULL_REGISTER	cpu_to_be32(0x40000000)
 
+static inline bool ipmr_pimsm_enabled(void)
+{
+	return IS_BUILTIN(CONFIG_IP_PIMSM_V1) || IS_BUILTIN(CONFIG_IP_PIMSM_V2);
+}
+
 /* PIMv2 register message header layout (ietf-draft-idmr-pimvsm-v2-00.ps */
 struct pimreghdr
 {
net/ipv4/ipmr.c +3 -8
index ff3dbbb9f11c..322fdc6ac75b 100644
@@ -75,11 +75,6 @@ struct ipmr_result {
 	struct mr_table		*mrt;
 };
 
-static inline bool pimsm_enabled(void)
-{
-	return IS_BUILTIN(CONFIG_IP_PIMSM_V1) || IS_BUILTIN(CONFIG_IP_PIMSM_V2);
-}
-
 /* Big lock, protecting vif table, mrt cache and mroute socket state.
  * Note that the changes are semaphored via rtnl_lock.
  */
@@ -751,7 +746,7 @@ static int vif_add(struct net *net, struct mr_table *mrt,
 
 	switch (vifc->vifc_flags) {
 	case VIFF_REGISTER:
-		if (!pimsm_enabled())
+		if (!ipmr_pimsm_enabled())
 			return -EINVAL;
 		/* Special Purpose VIF in PIM
 		 * All the packets will be sent to the daemon
@@ -1377,7 +1372,7 @@ int ip_mroute_setsockopt(struct sock *sk, int optname, char __user *optval,
 		mrt->mroute_do_assert = val;
 		break;
 	case MRT_PIM:
-		if (!pimsm_enabled()) {
+		if (!ipmr_pimsm_enabled()) {
 			ret = -ENOPROTOOPT;
 			break;
 		}
@@ -1451,7 +1446,7 @@ int ip_mroute_getsockopt(struct sock *sk, int optname, char __user *optval, int
 		val = 0x0305;
 		break;
 	case MRT_PIM:
-		if (!pimsm_enabled())
+		if (!ipmr_pimsm_enabled())
 			return -ENOPROTOOPT;
 		val = mrt->mroute_do_pim;
 		break;
Signature · 1 line
2.4.3
#6 lore raw

PATCH 6/7 net: ipmr: fix setsockopt error return

In reply to Nikolay Aleksandrov

From: Nikolay Aleksandrov <[email protected]>

We can have both errors and we'll return the second one, fix it to return an error at a time as it's normal. I've overlooked this in my previous set.

---
 net/ipv4/ipmr.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
net/ipv4/ipmr.c +5 -3
index 322fdc6ac75b..6c24a16299c7 100644
@@ -1284,12 +1284,14 @@ int ip_mroute_setsockopt(struct sock *sk, int optname, char __user *optval,
 
 	switch (optname) {
 	case MRT_INIT:
-		if (optlen != sizeof(int))
+		if (optlen != sizeof(int)) {
 			ret = -EINVAL;
-		if (rtnl_dereference(mrt->mroute_sk))
+			break;
+		}
+		if (rtnl_dereference(mrt->mroute_sk)) {
 			ret = -EADDRINUSE;
-		if (ret)
 			break;
+		}
 
 		ret = ip_ra_control(sk, 1, mrtsock_destruct);
 		if (ret == 0) {
Signature · 1 line
2.4.3
#7 lore raw

PATCH 7/7 net: ipmr: add mfc newroute/delroute netlink support

In reply to Nikolay Aleksandrov

From: Nikolay Aleksandrov <[email protected]>

This patch adds support to add and remove MFC entries. It uses the same attributes like the already present dump support in order to be consistent. There's one new entry - RTA_PREFSRC, it's used to denote an MFC_PROXY entry (see MRT_ADD_MFC vs MRT_ADD_MFC_PROXY).
The already existing infrastructure is used to create and delete the entries, the netlink message gets converted internally to a struct mfcctl which is used with ipmr_mfc_add/delete.
The other used attributes are:
RTA_IIF - used for mfcc_parent (when adding it's required to be valid) RTA_SRC - used for mfcc_origin
RTA_DST - used for mfcc_mcastgrp
RTA_TABLE - the MRT table id
RTA_MULTIPATH - the "oifs" ttl array

---
 net/ipv4/ipmr.c | 129 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 129 insertions(+)
net/ipv4/ipmr.c +129 -0
index 6c24a16299c7..1fa1024e23d0 100644
@@ -66,6 +66,7 @@
 #include <net/netlink.h>
 #include <net/fib_rules.h>
 #include <linux/netconf.h>
+#include <net/nexthop.h>
 
 struct ipmr_rule {
 	struct fib_rule		common;
@@ -2339,6 +2340,130 @@ done:
 	return skb->len;
 }
 
+static const struct nla_policy rtm_ipmr_policy[RTA_MAX + 1] = {
+	[RTA_SRC]	= { .type = NLA_U32 },
+	[RTA_DST]	= { .type = NLA_U32 },
+	[RTA_IIF]	= { .type = NLA_U32 },
+	[RTA_TABLE]	= { .type = NLA_U32 },
+	[RTA_MULTIPATH]	= { .len = sizeof(struct rtnexthop) },
+};
+
+static bool ipmr_rtm_validate_proto(unsigned char rtm_protocol)
+{
+	switch (rtm_protocol) {
+	case RTPROT_STATIC:
+	case RTPROT_MROUTED:
+		return true;
+	}
+	return false;
+}
+
+static int ipmr_nla_get_ttls(const struct nlattr *nla, struct mfcctl *mfcc)
+{
+	struct rtnexthop *rtnh = nla_data(nla);
+	int remaining = nla_len(nla), vifi = 0;
+
+	while (rtnh_ok(rtnh, remaining)) {
+		mfcc->mfcc_ttls[vifi] = rtnh->rtnh_hops;
+		if (++vifi == MAXVIFS)
+			break;
+		rtnh = rtnh_next(rtnh, &remaining);
+	}
+
+	return remaining > 0 ? -EINVAL : vifi;
+}
+
+/* returns < 0 on error, 0 for ADD_MFC and 1 for ADD_MFC_PROXY */
+static int rtm_to_ipmr_mfcc(struct net *net, struct nlmsghdr *nlh,
+			    struct mfcctl *mfcc, int *mrtsock,
+			    struct mr_table **mrtret)
+{
+	struct net_device *dev = NULL;
+	u32 tblid = RT_TABLE_DEFAULT;
+	struct mr_table *mrt;
+	struct nlattr *attr;
+	struct rtmsg *rtm;
+	int ret, rem;
+
+	ret = nlmsg_validate(nlh, sizeof(*rtm), RTA_MAX, rtm_ipmr_policy);
+	if (ret < 0)
+		goto out;
+	rtm = nlmsg_data(nlh);
+
+	ret = -EINVAL;
+	if (rtm->rtm_family != RTNL_FAMILY_IPMR || rtm->rtm_dst_len != 32 ||
+	    rtm->rtm_type != RTN_MULTICAST ||
+	    rtm->rtm_scope != RT_SCOPE_UNIVERSE ||
+	    !ipmr_rtm_validate_proto(rtm->rtm_protocol))
+		goto out;
+
+	memset(mfcc, 0, sizeof(*mfcc));
+	mfcc->mfcc_parent = -1;
+	ret = 0;
+	nlmsg_for_each_attr(attr, nlh, sizeof(struct rtmsg), rem) {
+		switch (nla_type(attr)) {
+		case RTA_SRC:
+			mfcc->mfcc_origin.s_addr = nla_get_be32(attr);
+			break;
+		case RTA_DST:
+			mfcc->mfcc_mcastgrp.s_addr = nla_get_be32(attr);
+			break;
+		case RTA_IIF:
+			dev = __dev_get_by_index(net, nla_get_u32(attr));
+			if (!dev) {
+				ret = -ENODEV;
+				goto out;
+			}
+			break;
+		case RTA_MULTIPATH:
+			if (ipmr_nla_get_ttls(attr, mfcc) < 0) {
+				ret = -EINVAL;
+				goto out;
+			}
+			break;
+		case RTA_PREFSRC:
+			ret = 1;
+			break;
+		case RTA_TABLE:
+			tblid = nla_get_u32(attr);
+			break;
+		}
+	}
+	mrt = ipmr_get_table(net, tblid);
+	if (!mrt) {
+		ret = -ENOENT;
+		goto out;
+	}
+	*mrtret = mrt;
+	*mrtsock = rtm->rtm_protocol == RTPROT_MROUTED ? 1 : 0;
+	if (dev)
+		mfcc->mfcc_parent = ipmr_find_vif(mrt, dev);
+
+out:
+	return ret;
+}
+
+/* takes care of both newroute and delroute */
+static int ipmr_rtm_route(struct sk_buff *skb, struct nlmsghdr *nlh)
+{
+	struct net *net = sock_net(skb->sk);
+	int ret, mrtsock, parent;
+	struct mr_table *tbl;
+	struct mfcctl mfcc;
+
+	mrtsock = 0;
+	tbl = NULL;
+	ret = rtm_to_ipmr_mfcc(net, nlh, &mfcc, &mrtsock, &tbl);
+	if (ret < 0)
+		return ret;
+
+	parent = ret ? mfcc.mfcc_parent : -1;
+	if (nlh->nlmsg_type == RTM_NEWROUTE)
+		return ipmr_mfc_add(net, tbl, &mfcc, mrtsock, parent);
+	else
+		return ipmr_mfc_delete(tbl, &mfcc, parent);
+}
+
 #ifdef CONFIG_PROC_FS
 /* The /proc interfaces to multicast routing :
  * /proc/net/ip_mr_cache & /proc/net/ip_mr_vif
@@ -2692,6 +2817,10 @@ int __init ip_mr_init(void)
 #endif
 	rtnl_register(RTNL_FAMILY_IPMR, RTM_GETROUTE,
 		      NULL, ipmr_rtm_dumproute, NULL);
+	rtnl_register(RTNL_FAMILY_IPMR, RTM_NEWROUTE,
+		      ipmr_rtm_route, NULL, NULL);
+	rtnl_register(RTNL_FAMILY_IPMR, RTM_DELROUTE,
+		      ipmr_rtm_route, NULL, NULL);
 	return 0;
 
 #ifdef CONFIG_IP_PIMSM_V2
Signature · 1 line
2.4.3
#8 lore raw
In reply to Nikolay Aleksandrov
Quoted 5 lines · Nikolay Aleksandrov

From: Nikolay Aleksandrov <[email protected]>

Hi,
This set continues with the minor cleanups in the first 6 patches and patch 7 adds the first new feature - MFC manipulation via netlink.

Hi Nikolay

Great to see somebody working on multicast.

Do you have any plans to remove the 32 VIF limit?

I've run out if VIFs on a VPN server with lots of clients. I took the "quick fix" of recompiling the kernel and userspace with 256 VIFs. But it would be nice if you could define a netlink API which does not have this limit and modify the core code to be more dynamic.

Andrew

#9 lore raw
Quoted 11 lines · Andrew Lunn
Quoted 5 lines · Nikolay Aleksandrov

From: Nikolay Aleksandrov <[email protected]>

Hi,
This set continues with the minor cleanups in the first 6 patches and patch 7 adds the first new feature - MFC manipulation via netlink.

Hi Nikolay

Great to see somebody working on multicast.

Quoted 9 lines

Do you have any plans to remove the 32 VIF limit?

I've run out if VIFs on a VPN server with lots of clients. I took the "quick fix" of recompiling the kernel and userspace with 256 VIFs. But it would be nice if you could define a netlink API which does not have this limit and modify the core code to be more dynamic.

Andrew

Hi Andrew,
I'm glad people are still using it. :-) To answer your question - yes, I plan to remove that limit, in fact I have a private version where it's done and this API is the first step, you can see it uses the generic rtnh which supports ifindex passing, so it'll be a matter of a few small changes to remove it. The hardest part is keeping current user-space compatible with everything, but I have the necessary workarounds for that. In the end it should be much more usable and to some extent without mrtsock application running as well.

Thanks,
Nik

maintainer
#10 lore raw
In reply to Nikolay Aleksandrov

From: Nikolay Aleksandrov <[email protected]>
Date: Thu, 26 Nov 2015 15:23:43 +0100

Quoted 9 lines

This set continues with the minor cleanups in the first 6 patches and patch 7 adds the first new feature - MFC manipulation via netlink. It registers NEWROUTE/DELROUTE for that purpose and uses the same semantics as the already present netlink dump. The only new attribute that is used is RTA_PREFSRC to denote an MFC_PROXY entry. Currently the table must exist before adding an entry, and new tables can be created only via setsockopt, but that will be changed in the future.
This set was tested with modified iproute2 which supports NEWROUTE/DELROUTE for RTNL_FAMILY_IPMR.

Looks great, series applied, thanks!