[Bug 194577] mbuf packet header leakage when closing TUN devices

2014-10-30 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=194577

--- Comment #12 from Hans Petter Selasky hsela...@freebsd.org ---
Created attachment 148792
  -- https://bugs.freebsd.org/bugzilla/attachment.cgi?id=148792action=edit
Cleanup altq before destroy

Hi,

While at it, I suggest you add the attached patch to the commit aswell. What do
you think?

--HPS

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
freebsd-bugs@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to freebsd-bugs-unsubscr...@freebsd.org


[Bug 194577] mbuf packet header leakage when closing TUN devices

2014-10-30 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=194577

--- Comment #13 from commit-h...@freebsd.org ---
A commit references this bug:

Author: ae
Date: Thu Oct 30 10:59:58 UTC 2014
New revision: 273855
URL: https://svnweb.freebsd.org/changeset/base/273855

Log:
  Fix mbuf leak in IPv6 multicast code.
  When multicast capable interface goes away, it leaves multicast groups,
  this leads to generate MLD reports, but MLD code does deffered send and
  MLD reports are queued in the in6_multi's in6m_scq ifq. The problem is
  that in6_multi structures are freed when interface leaves multicast groups
  and thread that does deffered send will not take these queued packets.

  PR:194577
  MFC after:1 week
  Sponsored by:Yandex LLC

Changes:
  head/sys/netinet6/in6_mcast.c

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
freebsd-bugs@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to freebsd-bugs-unsubscr...@freebsd.org


[Bug 194577] mbuf packet header leakage when closing TUN devices

2014-10-30 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=194577

Andrey V. Elsukov a...@freebsd.org changed:

   What|Removed |Added

 Status|Needs Triage|Needs MFC
   Assignee|freebsd-bugs@FreeBSD.org|a...@freebsd.org

--- Comment #14 from Andrey V. Elsukov a...@freebsd.org ---
Patched in head/.

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
freebsd-bugs@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to freebsd-bugs-unsubscr...@freebsd.org


[Bug 194577] mbuf packet header leakage when closing TUN devices

2014-10-29 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=194577

--- Comment #10 from Andrey V. Elsukov a...@freebsd.org ---
Created attachment 148778
  -- https://bugs.freebsd.org/bugzilla/attachment.cgi?id=148778action=edit
Proposed patch

Hi, Hans,

can you try this patch?
My investigations led me to the following conclusions.
The leak isn't specific to tun(4) device, it could be reproduced with any
device where MLD works.

The backtrace to the allocation that will not be freed is

uma_zalloc_arg
mld_v2_enqueue_group_record+0x678
mld_change_state+0x3b9
in6_mc_join_locked+0x346
in6_mc_join+0x94
in6_joingroup+0x58
in6_update_ifa+0xd2c
in6_ifattach+0x506
ifioctl+0x8e0
kern_ioctl+0x3cd
sys_ioctl+0x13c

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
freebsd-bugs@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to freebsd-bugs-unsubscr...@freebsd.org


[Bug 194577] mbuf packet header leakage when closing TUN devices

2014-10-29 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=194577

--- Comment #11 from Hans Petter Selasky hsela...@freebsd.org ---
Hi,

I see no more buffer leakages currently. I'll let you know if I find more.

Don't forget to MFC to 9- and 10- stable. Might be possible to get it in before
10.1-R too ...

--HPS

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
freebsd-bugs@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to freebsd-bugs-unsubscr...@freebsd.org


[Bug 194577] mbuf packet header leakage when closing TUN devices

2014-10-28 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=194577

--- Comment #9 from Hans Petter Selasky hsela...@freebsd.org ---
Hi,

Here is how to reproduce:

FreeBSD-9-stable:

1) install openvpn from ports
2) generate an openvpn key
3) start two instances of openvpn like this (no need for a client!)

/usr/local/sbin/openvpn --keepalive 120 240 --float --lport 543 --dev tun3 \
 --ifconfig 10.1.2.6 10.1.2.7 \
 --secret .key --daemon testlink

/usr/local/sbin/openvpn --proto tcp_server --keepalive 120 240 --float --lport
544 --dev tun4 \
 --ifconfig 10.1.2.8 10.1.2.9 \
 --secret .key --daemon testlink2

4) watch

vmstat -z | grep -E LIMIT|mbuf:

After some minutes, the number of mbufs in use starts growing simply.

Maybe that's simpler for you to reproduce?

--HPS

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
freebsd-bugs@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to freebsd-bugs-unsubscr...@freebsd.org


[Bug 194577] mbuf packet header leakage when closing TUN devices

2014-10-27 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=194577

Andrey V. Elsukov a...@freebsd.org changed:

   What|Removed |Added

 CC||a...@freebsd.org

--- Comment #2 from Andrey V. Elsukov a...@freebsd.org ---
Hi, Hans,

If I understand correctly, you are able to track what mbuf were allocated and
not freed in some period. Is it possible to modify your patch for printing
content of these mbufs? I mean something like this:

struct ip *ip;
struct ip6_hdr *ip6;

if (m-m_len  sizeof(struct ip)) {
  ip = mtod(m, struct ip*);
  printf(IP version: %u\n, ip-ip_v);
  switch(ip-ip_v) {
  case IPVERSION:
  /* print ip_src, ip_dst, ip_p */
  break;
  case (IPV6_VERSION  4):
  ip6 = mtod(m, struct ip6_hdr *);
  /* print ip6_src, ip6_dst, ip6_nxt */
  break;
  }
}

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
freebsd-bugs@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to freebsd-bugs-unsubscr...@freebsd.org


[Bug 194577] mbuf packet header leakage when closing TUN devices

2014-10-27 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=194577

--- Comment #3 from Hans Petter Selasky hsela...@freebsd.org ---
Yes, can you send me a working example code with everything you want to print,
and I'll add it to the kernel, taking a struct mbuf * as input.

--HPS

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
freebsd-bugs@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to freebsd-bugs-unsubscr...@freebsd.org


[Bug 194577] mbuf packet header leakage when closing TUN devices

2014-10-27 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=194577

--- Comment #5 from Andrey V. Elsukov a...@freebsd.org ---
the function is untested, so be careful :)

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
freebsd-bugs@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to freebsd-bugs-unsubscr...@freebsd.org


[Bug 194577] mbuf packet header leakage when closing TUN devices

2014-10-27 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=194577

--- Comment #4 from Andrey V. Elsukov a...@freebsd.org ---
Created attachment 148695
  -- https://bugs.freebsd.org/bugzilla/attachment.cgi?id=148695action=edit
kernel function for printing mbuf info

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
freebsd-bugs@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to freebsd-bugs-unsubscr...@freebsd.org


[Bug 194577] mbuf packet header leakage when closing TUN devices

2014-10-27 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=194577

--- Comment #6 from Hans Petter Selasky hsela...@freebsd.org ---
Testing right now. You will have the result soonish ...

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
freebsd-bugs@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to freebsd-bugs-unsubscr...@freebsd.org


[Bug 194577] mbuf packet header leakage when closing TUN devices

2014-10-27 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=194577

--- Comment #7 from Hans Petter Selasky hsela...@freebsd.org ---
Hi,

Here are the candidates for lost mbufs:

Stuck MBUF[2] TID=100082 LEN=0
mbuf 0xc3265e00: len 20, flags 0x0002
mbuf 0xc3265e00: ip_v 0
Stuck MBUF[3] TID=100087 LEN=0
mbuf 0xc2b04e00: len 20, flags 0x0002
mbuf 0xc2b04e00: ip_v 0
Stuck MBUF[5] TID=100087 LEN=0
mbuf 0xc2b02900: len 20, flags 0x0002
mbuf 0xc2b02900: ip_v 0
Stuck MBUF[22] TID=100082 LEN=0
mbuf 0xc2b05100: len 20, flags 0x0002
mbuf 0xc2b05100: ip_v 0
Stuck MBUF[23] TID=100082 LEN=0
mbuf 0xc2b07600: len 20, flags 0x0002
mbuf 0xc2b07600: ip_v 0
Stuck MBUF[89] TID=100087 LEN=0
mbuf 0xc325da00: len 20, flags 0x0002
mbuf 0xc325da00: ip_v 0 

Note, this is 9-stable, so the M_PRINT_FLAGS was not there, and I used 0x%08x
instead.

--HPS

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
freebsd-bugs@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to freebsd-bugs-unsubscr...@freebsd.org


[Bug 194577] mbuf packet header leakage when closing TUN devices

2014-10-27 Thread bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=194577

--- Comment #8 from Andrey V. Elsukov a...@freebsd.org ---
Comment on attachment 148695
  -- https://bugs.freebsd.org/bugzilla/attachment.cgi?id=148695
kernel function for printing mbuf info

   printf(mbuf %p: len %u, flags %b\n, m, m-m_len,
   m-m_flags, M_FLAG_PRINTF);

Nothing specific :(
It seems the last what here can be interesting is the following:

if (m-m_flags  M_PKTHDR)
  printf(  hdrlen %u\n, m, m-m_pkthdr.len)

   if (m-m_len  sizeof(struct ip))
   return;

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
freebsd-bugs@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to freebsd-bugs-unsubscr...@freebsd.org