Issue
I'm using pimd in my project. https://github.com/troglobit/pimd. PIM daemon creates a 'pimreg' virtual interface. Multicast routing works perfectly. but I'm curious why do we need 'pimreg' interface at all.
The code which handles virtual interface creation in kernel is:
static struct net_device *ipmr_reg_vif(struct net *net, struct mr_table *mrt)
{
struct net_device *dev;
struct in_device *in_dev;
char name[IFNAMSIZ];
if (mrt->id == RT_TABLE_DEFAULT)
sprintf(name, "pimreg");
else
sprintf(name, "pimreg%u", mrt->id);
dev = alloc_netdev(0, name, reg_vif_setup);
if (dev == NULL)
return NULL;
dev_net_set(dev, net);
if (register_netdevice(dev)) {
free_netdev(dev);
return NULL;
}
dev->iflink = 0;
rcu_read_lock();
in_dev = __in_dev_get_rcu(dev);
if (!in_dev) {
rcu_read_unlock();
goto failure;
}
ipv4_devconf_setall(in_dev);
IPV4_DEVCONF(in_dev->cnf, RP_FILTER) = 0;
rcu_read_unlock();
if (dev_open(dev))
goto failure;
dev_hold(dev);
return dev;
failure:
/* allow the register to be completed before unregistering. */
rtnl_unlock();
rtnl_lock();
unregister_netdevice(dev);
return NULL;
}
and I see most of the time tx and rx packets are 0.
ifconfig pimreg
pimreg: flags=193<UP,RUNNING,NOARP> mtu 1472
unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 txqueuelen 0 (UNSPEC)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
On further debugging I found all PIM packets are lifted from kernel to userspace through pim_socket. So why do we need pimreg virtual interface on first place? What is the linux kernel pimd design objective for this.
Solution
The pimreg
interface is created by the kernel when pimd
opens
the multicast routing socket and performs its ioctl
magic.
The interface is used for register tunnels, i.e. when tunneling multicast stream(s) from the rendez-vous point (RP) to the designated router (DR).
More information about this is available in RFC4601.
Answered By - troglobit Answer Checked By - Timothy Miller (WPSolving Admin)