public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Alexander Clouter <alex@digriz•org.uk>
To: netdev@vger•kernel.org
Subject: pimreg zombies
Date: Sat, 4 Sep 2010 22:12:34 +0100	[thread overview]
Message-ID: <2bpal7-l68.ln1@chipmunk.wormnet.eu> (raw)

Hi,

I am writing a multicast pim daemon and noticed that if I call 
setsockopt(MRT_ADD_VIF), also occurs for IPv6 too, incorrectly on a 
socket established with socket(AF_INET, SOCK_RAW, IPPROTO_PIM)[1] then 
when the application quits I have zombie pimreg (and pimreg6) interfaces 
that can only be disposed of with a reboot.

I have included the code below to give you something (hopefully) 
reproducible; this problem I see on a 2.6.35.4 kernel.  No idea if there 
was ever a safe kernel but maybe all the recent namespace and multiple 
multicast routing table amendments broke something.

Obviously I know for Linux I should be calling setsockopt() on the IGMP 
socket, however I'm pretty sure zombie pim's should not be appearing :)

Cheers

[1] rather than as I should on an IPPROTO_IGMP raw socket

----
#include <sys/types.h>
#include <sys/socket.h>
#include <unistd.h>
#include <stdio.h>
#include <sysexits.h>
#include <string.h>
#include <netinet/in.h>
#include <linux/mroute.h>
#include <linux/mroute6.h>

int main(int argc, char **argv)
{
	int		pim4, pim6;
	struct vifctl	v4;
	struct mif6ctl	v6;

	pim4 = socket(AF_INET, SOCK_RAW, IPPROTO_PIM);
	if (pim4 < 0) {
		perror("socket(AF_INET, SOCK_RAW, IPPROTO_PIM)");
		return EX_OSERR;
	}

	memset(&v4, 0, sizeof(v4));
	v4.vifc_flags	= VIFF_REGISTER;

	if (setsockopt(pim4, IPPROTO_IP, MRT_ADD_VIF, &v4, sizeof(v4)) < 0) {
		perror("setsockopt(MRT_ADD_VIF)");
		close(pim4);
		return EX_OSERR;
	}

	close(pim4);

	/***********************/

	pim6 = socket(AF_INET6, SOCK_RAW, IPPROTO_PIM);
	if (pim6 < 0) {
		perror("socket(AF_INET6, SOCK_RAW, IPPROTO_PIM)");
		return EX_OSERR;
	}

	memset(&v6, 0, sizeof(v6));
	v6.mif6c_flags = MIFF_REGISTER;

	if (setsockopt(pim6, IPPROTO_IPV6, MRT6_ADD_MIF, &v6, sizeof(v6)) < 0) {
		perror("setsockopt(MRT6_ADD_MIF)");
		close(pim6);
		return EX_OSERR;
	}

	close(pim6);

	return EX_OK;
}
----

-- 
Alexander Clouter
.sigmonster says: You have junk mail.


             reply	other threads:[~2010-09-04 22:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-04 21:12 Alexander Clouter [this message]
2010-09-12 19:08 ` pimreg zombies David Miller
2010-09-12 19:17 ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2bpal7-l68.ln1@chipmunk.wormnet.eu \
    --to=alex@digriz$(echo .)org.uk \
    --cc=netdev@vger$(echo .)kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox