NetBSD Problem Report #51301

From paul@whooppee.com  Sat Jul  2 01:19:41 2016
Return-Path: <paul@whooppee.com>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (verified OK))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 7055B7A21F
	for <gnats-bugs@gnats.NetBSD.org>; Sat,  2 Jul 2016 01:19:41 +0000 (UTC)
Message-Id: <20160702011940.253DB6FCE0@vps1.whooppee.com>
Date: Sat,  2 Jul 2016 09:19:40 +0800 (PHT)
From: paul@whooppee.com
Reply-To: paul@whooppee.com
To: gnats-bugs@gnats.NetBSD.org
Subject: 7.99.32 has broken IPv6 functionality of pkgsrc/net/openvpn
X-Send-Pr-Version: 3.95

>Number:         51301
>Category:       kern
>Synopsis:       7.99.32 has broken IPv6 functionality of pkgsrc/net/openvpn
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    kern-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Jul 02 01:20:00 +0000 2016
>Closed-Date:    Tue Jul 05 02:18:54 +0000 2016
>Last-Modified:  Tue Jul 05 02:18:54 +0000 2016
>Originator:     Paul Goyette
>Release:        NetBSD 7.99.32
>Organization:
+------------------+--------------------------+------------------------+
| Paul Goyette     | PGP Key fingerprint:     | E-mail addresses:      |
| (Retired)        | FA29 0E3B 35AF E8AE 6651 | paul at whooppee.com   |
| Kernel Developer | 0786 F758 55DE 53BA 7731 | pgoyette at netbsd.org |
+------------------+--------------------------+------------------------+
>Environment:


System: NetBSD pokey.whooppee.com 7.99.32 NetBSD 7.99.32 (POKEY 2016-06-30 09:34:28) #0: Thu Jun 30 19:56:16 PHT 2016  paul@pokey.whooppee.com:/build/netbsd-local/obj/amd64/sys/arch/amd64/compile/POKEY amd64
Architecture: x86_64
Machine: amd64
>Description:
I have a machine at home which has only IPv4 connectivity, and that is
behind a IP-NAT DSL router.  No fixed address is available from the ISP.

I have a globally-routable IPv6 address block allocated to me from
another ISP (a XEN-based virtual machine hosted in the US), so I usually
run net/openvpn to create a tunnel between the XEN machine and my local
machine.

All of this worked when I was running 7.99.30 kernel+userland.

But now that I've updated both kernel and userland to 7.99.32 (from
about 24 hours ago), the tunnel is not passing an IPv6 traffic.  It
still works for IPv4.

This is with a simple set-up with the following config files:

On the 7.99.32 machine, I have

# cat /usr/pkg/etc/openvpn/pokey-vps1.conf
dev tun
tun-ipv6
remote vps1.whooppee.com
ifconfig 172.16.1.2 172.16.1.1
ifconfig-ipv6 2605:2700:1:1043::2/120 2605:2700:1:1043::1
route-ipv6 ::/0
ping 10
<secret>
# 
# 2048 bit OpenVPN static key
# 
-----BEGIN OpenVPN Static key V1-----
...
-----END OpenVPN Static key V1-----
#


And on the XEN-based machine, I have

# cat /usr/pkg/etc/openvpn/vps1-pokey.conf
dev tun
tun-ipv6
#remote 112.209.159.18
ifconfig 172.16.1.1  172.16.1.2
ifconfig-ipv6 2605:2700:1:1043::1/120 2605:2700:1:1043::2
ping 10
<secret>
#
# 2048 bit OpenVPN static key
#
-----BEGIN OpenVPN Static key V1-----
...
-----END OpenVPN Static key V1-----
#


If I ping6 from the the XEN machine towards the 7.99.32 machine, the 
packets are received, but no response is sent.  If I enable ipv6 forwarding
on the 7.99.32 machine, it attempts to reply with an ICMP6 Destination
Unreachable, even though there is a route for the destination:

2605:2700:1:1043::/120                  link#3                         UC          -        -      -  tun0
2605:2700:1:1043::2                     tun0                           UHl         -        -      -  tun0

Note, however, that the ::2 address has both Gateway and Interface set to
the tunnel interface. On the XEN-based machine we see

2605:2700:1:1043::/120             link#3             UC          0       22      -  tun0
2605:2700:1:1043::1                link#3             UHL         1        6      -  lo0

where the Gateway is link#3 and the Interface is lo0 !!


This used to work on 7.99.30 .....


>How-To-Repeat:

>Fix:


>Release-Note:

>Audit-Trail:
From: Paul Goyette <paul@whooppee.com>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: kern/51301: 7.99.32 has broken IPv6 functionality of pkgsrc/net/openvpn
Date: Sat, 2 Jul 2016 14:55:28 +0800 (PHT)

 Bisecting the time period between working and non-working kernels gets 
 us to the following commit.  A kernel built from sources just before 
 this commit works, while a kernel built from after the commits fails.

 Module Name:    src
 Committed By:   ozaki-r
 Date:           Thu Jun 30 01:34:53 UTC 2016

 Modified Files:
          src/sys/net: if_spppsubr.c
          src/sys/netinet: if_arp.c in.c
          src/sys/netinet6: in6.c nd6.c

 Log Message:
 Make sure that ifaddr is published after its initialization finished

 Basically we should insert an item to a collection (say a list) after
 item's initialization has been completed to avoid accessing an item
 that is initialized halfway. ifaddr (in{,6}_ifaddr) isn't processed
 like so and needs to be fixed.

 In order to do so, we need to tweak {arp,nd6}_rtrequest that depend
 on that an ifaddr is inserted during its initialization; they explore
 interface's address list to determine that rt_getkey(rt) of a given
 rtentry is in the list to know whether the route's interface should
 be a loopback, which doesn't work after the change. To make it work,
 first check RTF_LOCAL flag that is set in rt_ifa_addlocal that calls
 {arp,nd6}_rtrequest eventually. Note that we still need the original
 code for the case to remove and re-add a local interface route.


 To generate a diff of this commit:
 cvs rdiff -u -r1.143 -r1.144 src/sys/net/if_spppsubr.c
 cvs rdiff -u -r1.213 -r1.214 src/sys/netinet/if_arp.c
 cvs rdiff -u -r1.168 -r1.169 src/sys/netinet/in.c
 cvs rdiff -u -r1.201 -r1.202 src/sys/netinet6/in6.c
 cvs rdiff -u -r1.197 -r1.198 src/sys/netinet6/nd6.c



 +------------------+--------------------------+------------------------+
 | Paul Goyette     | PGP Key fingerprint:     | E-mail addresses:      |
 | (Retired)        | FA29 0E3B 35AF E8AE 6651 | paul at whooppee.com   |
 | Kernel Developer | 0786 F758 55DE 53BA 7731 | pgoyette at netbsd.org |
 +------------------+--------------------------+------------------------+

From: Ryota Ozaki <ozaki-r@netbsd.org>
To: "gnats-bugs@NetBSD.org" <gnats-bugs@netbsd.org>
Cc: kern-bug-people@netbsd.org, gnats-admin@netbsd.org, netbsd-bugs@netbsd.org, 
	Paul Goyette <paul@whooppee.com>
Subject: Re: kern/51301: 7.99.32 has broken IPv6 functionality of pkgsrc/net/openvpn
Date: Sat, 2 Jul 2016 18:00:24 +0900

 On Sat, Jul 2, 2016 at 4:00 PM, Paul Goyette <paul@whooppee.com> wrote:
 > The following reply was made to PR kern/51301; it has been noted by GNATS.
 >
 > From: Paul Goyette <paul@whooppee.com>
 > To: gnats-bugs@NetBSD.org
 > Cc:
 > Subject: Re: kern/51301: 7.99.32 has broken IPv6 functionality of pkgsrc/net/openvpn
 > Date: Sat, 2 Jul 2016 14:55:28 +0800 (PHT)
 >
 >  Bisecting the time period between working and non-working kernels gets
 >  us to the following commit.  A kernel built from sources just before
 >  this commit works, while a kernel built from after the commits fails.

 Thank your for the investigation. Could you provide outputs of
 ifconfig tun0 and netstat -nr -f inet6 with kernels w/ and w/o the commit?

   ozaki-r

 >
 >  Module Name:    src
 >  Committed By:   ozaki-r
 >  Date:           Thu Jun 30 01:34:53 UTC 2016
 >
 >  Modified Files:
 >           src/sys/net: if_spppsubr.c
 >           src/sys/netinet: if_arp.c in.c
 >           src/sys/netinet6: in6.c nd6.c
 >
 >  Log Message:
 >  Make sure that ifaddr is published after its initialization finished
 >
 >  Basically we should insert an item to a collection (say a list) after
 >  item's initialization has been completed to avoid accessing an item
 >  that is initialized halfway. ifaddr (in{,6}_ifaddr) isn't processed
 >  like so and needs to be fixed.
 >
 >  In order to do so, we need to tweak {arp,nd6}_rtrequest that depend
 >  on that an ifaddr is inserted during its initialization; they explore
 >  interface's address list to determine that rt_getkey(rt) of a given
 >  rtentry is in the list to know whether the route's interface should
 >  be a loopback, which doesn't work after the change. To make it work,
 >  first check RTF_LOCAL flag that is set in rt_ifa_addlocal that calls
 >  {arp,nd6}_rtrequest eventually. Note that we still need the original
 >  code for the case to remove and re-add a local interface route.
 >
 >
 >  To generate a diff of this commit:
 >  cvs rdiff -u -r1.143 -r1.144 src/sys/net/if_spppsubr.c
 >  cvs rdiff -u -r1.213 -r1.214 src/sys/netinet/if_arp.c
 >  cvs rdiff -u -r1.168 -r1.169 src/sys/netinet/in.c
 >  cvs rdiff -u -r1.201 -r1.202 src/sys/netinet6/in6.c
 >  cvs rdiff -u -r1.197 -r1.198 src/sys/netinet6/nd6.c
 >
 >
 >
 >  +------------------+--------------------------+------------------------+
 >  | Paul Goyette     | PGP Key fingerprint:     | E-mail addresses:      |
 >  | (Retired)        | FA29 0E3B 35AF E8AE 6651 | paul at whooppee.com   |
 >  | Kernel Developer | 0786 F758 55DE 53BA 7731 | pgoyette at netbsd.org |
 >  +------------------+--------------------------+------------------------+
 >

From: Paul Goyette <paul@whooppee.com>
To: Ryota Ozaki <ozaki-r@netbsd.org>
Cc: "gnats-bugs@NetBSD.org" <gnats-bugs@netbsd.org>, 
    kern-bug-people@netbsd.org, gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Subject: Re: kern/51301: 7.99.32 has broken IPv6 functionality of pkgsrc/net/openvpn
Date: Sat, 2 Jul 2016 18:43:25 +0800 (PHT)

 > Thank your for the investigation. Could you provide outputs of
 > ifconfig tun0 and netstat -nr -f inet6 with kernels w/ and w/o the commit?

 # Output from working kernel, built from sources immediately PRIOR TO
 # the suspect commit

 # ifconfig tun0

 tun0: flags=0x8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1500
  	inet 172.16.1.2 -> 172.16.1.1 netmask 0xffffffff
  	inet6 fe80::32b5:c2ff:fe05:e66%tun0 ->  prefixlen 64 scopeid 0x3
  	inet6 2605:2700:1:1043::2 ->  prefixlen 120

 --------------------

 # netstat -nr -f inet6

 Routing tables

 Internet6:
 Destination                             Gateway                        Flags    Refs      Use    Mtu Interface
 ::/104                                  ::1                            UGRS        -        -  33624L lo0
 ::/96                                   ::1                            UGRS        -        -  33624L lo0
 default                                 2605:2700:1:1043::1            UGS         -        -      -L tun0
 ::1                                     ::1                            UH          -        -  33624L lo0
 ::127.0.0.0/104                         ::1                            UGRS        -        -  33624L lo0
 ::224.0.0.0/100                         ::1                            UGRS        -        -  33624L lo0
 ::255.0.0.0/104                         ::1                            UGRS        -        -  33624L lo0
 ::ffff:0.0.0.0/96                       ::1                            UGRS        -        -  33624L lo0
 2001:db8::/32                           ::1                            UGRS        -        -  33624L lo0
 2002::/24                               ::1                            UGRS        -        -  33624L lo0
 2002:7f00::/24                          ::1                            UGRS        -        -  33624L lo0
 2002:e000::/20                          ::1                            UGRS        -        -  33624L lo0
 2002:ff00::/24                          ::1                            UGRS        -        -  33624L lo0
 2605:2700:1:1043::/120                  link#3                         UC          -        -      -L tun0
 2605:2700:1:1043::2                     tun0                           UHl         -        -      -L lo0
 fe80::/10                               ::1                            UGRS        -        -  33624L lo0
 fe80::%re0/64                           link#1                         UC          -        -      -L re0
 fe80::2766:a3b0:b51c:e2c3               link#1                         UHl         -        -      -L lo0
 fe80::%lo0/64                           fe80::1                        U           -        -      -L lo0
 fe80::1                                 lo0                            UHl         -        -      -L lo0
 fe80::%tun0/64                          link#3                         UC          -        -      -L tun0
 fe80::32b5:c2ff:fe05:e66                tun0                           UHl         -        -      -L lo0
 ff01:1::/32                             link#1                         UC          -        -      -L re0
 ff01:2::/32                             ::1                            UC          -        -  33624L lo0
 ff01:3::/32                             fe80::32b5:c2ff:fe05:e66       UC          -        -      -L tun0
 ff02::%re0/32                           link#1                         UC          -        -      -L re0
 ff02::%lo0/32                           ::1                            UC          -        -  33624L lo0
 ff02::%tun0/32                          fe80::32b5:c2ff:fe05:e66       UC          -        -      -L tun0

 # Output from working kernel, built from sources immediately AFTER
 # the suspect commit

 # ifconfig tun0

 tun0: flags=0x8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1500
  	inet 172.16.1.2 -> 172.16.1.1 netmask 0xffffffff
  	inet6 fe80::32b5:c2ff:fe05:e66%tun0 ->  prefixlen 64 scopeid 0x3
  	inet6 2605:2700:1:1043::2 ->  prefixlen 120

 # netstat -rn -f inet6

 Routing tables

 Internet6:
 Destination                             Gateway                        Flags    Refs      Use    Mtu Interface
 ::/104                                  ::1                            UGRS        -        -  33624  lo0
 ::/96                                   ::1                            UGRS        -        -  33624  lo0
 default                                 2605:2700:1:1043::1            UGS         -        -      -  tun0
 ::1                                     ::1                            UH          -        -  33624  lo0
 ::127.0.0.0/104                         ::1                            UGRS        -        -  33624  lo0
 ::224.0.0.0/100                         ::1                            UGRS        -        -  33624  lo0
 ::255.0.0.0/104                         ::1                            UGRS        -        -  33624  lo0
 ::ffff:0.0.0.0/96                       ::1                            UGRS        -        -  33624  lo0
 2001:db8::/32                           ::1                            UGRS        -        -  33624  lo0
 2002::/24                               ::1                            UGRS        -        -  33624  lo0
 2002:7f00::/24                          ::1                            UGRS        -        -  33624  lo0
 2002:e000::/20                          ::1                            UGRS        -        -  33624  lo0
 2002:ff00::/24                          ::1                            UGRS        -        -  33624  lo0
 2605:2700:1:1043::/120                  link#3                         UC          -        -      -  tun0
 2605:2700:1:1043::2                     tun0                           UHl         -        -      -  tun0
 fe80::/10                               ::1                            UGRS        -        -  33624  lo0
 fe80::%re0/64                           link#1                         UC          -        -      -  re0
 fe80::2766:a3b0:b51c:e2c3               link#1                         UHl         -        -      -  lo0
 fe80::%lo0/64                           fe80::1                        U           -        -      -  lo0
 fe80::1                                 lo0                            UHl         -        -      -  lo0
 fe80::%tun0/64                          link#3                         UC          -        -      -  tun0
 fe80::32b5:c2ff:fe05:e66                tun0                           UHl         -        -      -  tun0
 ff01:1::/32                             link#1                         UC          -        -      -  re0
 ff01:2::/32                             ::1                            UC          -        -  33624  lo0
 ff01:3::/32                             fe80::32b5:c2ff:fe05:e66       UC          -        -      -  tun0
 ff02::%re0/32                           link#1                         UC          -        -      -  re0
 ff02::%lo0/32                           ::1                            UC          -        -  33624  lo0
 ff02::%tun0/32                          fe80::32b5:c2ff:fe05:e66       UC          -        -      -  tun0


 +------------------+--------------------------+------------------------+
 | Paul Goyette     | PGP Key fingerprint:     | E-mail addresses:      |
 | (Retired)        | FA29 0E3B 35AF E8AE 6651 | paul at whooppee.com   |
 | Kernel Developer | 0786 F758 55DE 53BA 7731 | pgoyette at netbsd.org |
 +------------------+--------------------------+------------------------+

From: Paul Goyette <paul@whooppee.com>
To: Ryota Ozaki <ozaki-r@netbsd.org>, gnats-bugs@netbsd.org
Cc: 
Subject: Re: kern/51301: 7.99.32 has broken IPv6 functionality of pkgsrc/net/openvpn
Date: Sat, 2 Jul 2016 18:54:08 +0800 (PHT)

 Looking at the two outputs side-by-side, the only significant 
 differences are:

 * The "L" flag is missing in the "after" output

 * For 2605:2700:1:1043::1:2 in the "after" file, the interface is tun0
    In the "before" file, that route has interface lo0

 Also please note that the openvpn software apparently tries to add that 
 ::1:2 route twice;  I get the following message in startup log

 route: writing to routing socket: File exists
 add net 2605:2700:1:1043::/120: gateway 2605:2700:1:1043::2: File exists

 But I also get this when everything works, and I even get it on NetBSD-6 
 so it may not be significant.


 +------------------+--------------------------+------------------------+
 | Paul Goyette     | PGP Key fingerprint:     | E-mail addresses:      |
 | (Retired)        | FA29 0E3B 35AF E8AE 6651 | paul at whooppee.com   |
 | Kernel Developer | 0786 F758 55DE 53BA 7731 | pgoyette at netbsd.org |
 +------------------+--------------------------+------------------------+

From: Ryota Ozaki <ozaki-r@netbsd.org>
To: Paul Goyette <paul@whooppee.com>
Cc: "gnats-bugs@NetBSD.org" <gnats-bugs@netbsd.org>
Subject: Re: kern/51301: 7.99.32 has broken IPv6 functionality of pkgsrc/net/openvpn
Date: Sat, 2 Jul 2016 22:37:27 +0900

 On Sat, Jul 2, 2016 at 7:54 PM, Paul Goyette <paul@whooppee.com> wrote:
 > Looking at the two outputs side-by-side, the only significant differences
 > are:
 >
 > * The "L" flag is missing in the "after" output

 This is expected. Updating userland led the change.

 >
 > * For 2605:2700:1:1043::1:2 in the "after" file, the interface is tun0
 >   In the "before" file, that route has interface lo0

 So the diff should be important for the issue. Could you test
 a kernel with only r1.198 of src/sys/netinet6/nd6.c reverted?
 The change looks related to the issue.

 >
 > Also please note that the openvpn software apparently tries to add that
 > ::1:2 route twice;  I get the following message in startup log
 >
 > route: writing to routing socket: File exists
 > add net 2605:2700:1:1043::/120: gateway 2605:2700:1:1043::2: File exists

 I'm not sure if the behavior affects the kernel or not
 (I guess not).

 Thanks,
   ozaki-r

 >
 > But I also get this when everything works, and I even get it on NetBSD-6 so
 > it may not be significant.
 >
 >
 >
 > +------------------+--------------------------+------------------------+
 > | Paul Goyette     | PGP Key fingerprint:     | E-mail addresses:      |
 > | (Retired)        | FA29 0E3B 35AF E8AE 6651 | paul at whooppee.com   |
 > | Kernel Developer | 0786 F758 55DE 53BA 7731 | pgoyette at netbsd.org |
 > +------------------+--------------------------+------------------------+

From: Ryota Ozaki <ozaki-r@netbsd.org>
To: Paul Goyette <paul@whooppee.com>
Cc: "gnats-bugs@NetBSD.org" <gnats-bugs@netbsd.org>
Subject: Re: kern/51301: 7.99.32 has broken IPv6 functionality of pkgsrc/net/openvpn
Date: Sat, 2 Jul 2016 23:00:50 +0900

 On Sat, Jul 2, 2016 at 10:37 PM, Ryota Ozaki <ozaki-r@netbsd.org> wrote:
 > On Sat, Jul 2, 2016 at 7:54 PM, Paul Goyette <paul@whooppee.com> wrote:
 >> Looking at the two outputs side-by-side, the only significant differences
 >> are:
 >>
 >> * The "L" flag is missing in the "after" output
 >
 > This is expected. Updating userland led the change.
 >
 >>
 >> * For 2605:2700:1:1043::1:2 in the "after" file, the interface is tun0
 >>   In the "before" file, that route has interface lo0
 >
 > So the diff should be important for the issue. Could you test
 > a kernel with only r1.198 of src/sys/netinet6/nd6.c reverted?
 > The change looks related to the issue.

 Oops. Only reverting the change doesn't work.
 I'll investigate more to know what's happening.

   ozaki-r

 >
 >>
 >> Also please note that the openvpn software apparently tries to add that
 >> ::1:2 route twice;  I get the following message in startup log
 >>
 >> route: writing to routing socket: File exists
 >> add net 2605:2700:1:1043::/120: gateway 2605:2700:1:1043::2: File exists
 >
 > I'm not sure if the behavior affects the kernel or not
 > (I guess not).
 >
 > Thanks,
 >   ozaki-r
 >
 >>
 >> But I also get this when everything works, and I even get it on NetBSD-6 so
 >> it may not be significant.
 >>
 >>
 >>
 >> +------------------+--------------------------+------------------------+
 >> | Paul Goyette     | PGP Key fingerprint:     | E-mail addresses:      |
 >> | (Retired)        | FA29 0E3B 35AF E8AE 6651 | paul at whooppee.com   |
 >> | Kernel Developer | 0786 F758 55DE 53BA 7731 | pgoyette at netbsd.org |
 >> +------------------+--------------------------+------------------------+

From: Ryota Ozaki <ozaki-r@netbsd.org>
To: Paul Goyette <paul@whooppee.com>
Cc: "gnats-bugs@NetBSD.org" <gnats-bugs@netbsd.org>
Subject: Re: kern/51301: 7.99.32 has broken IPv6 functionality of pkgsrc/net/openvpn
Date: Sat, 2 Jul 2016 23:17:15 +0900

 On Sat, Jul 2, 2016 at 11:00 PM, Ryota Ozaki <ozaki-r@netbsd.org> wrote:
 > On Sat, Jul 2, 2016 at 10:37 PM, Ryota Ozaki <ozaki-r@netbsd.org> wrote:
 >> On Sat, Jul 2, 2016 at 7:54 PM, Paul Goyette <paul@whooppee.com> wrote:
 >>> Looking at the two outputs side-by-side, the only significant differences
 >>> are:
 >>>
 >>> * The "L" flag is missing in the "after" output
 >>
 >> This is expected. Updating userland led the change.
 >>
 >>>
 >>> * For 2605:2700:1:1043::1:2 in the "after" file, the interface is tun0
 >>>   In the "before" file, that route has interface lo0
 >>
 >> So the diff should be important for the issue. Could you test
 >> a kernel with only r1.198 of src/sys/netinet6/nd6.c reverted?
 >> The change looks related to the issue.
 >
 > Oops. Only reverting the change doesn't work.
 > I'll investigate more to know what's happening.

 Does the following patch help you?

 Thanks,
   ozaki-r

 diff --git a/sys/net/if.c b/sys/net/if.c
 index dc73c47..62e58c8 100644
 --- a/sys/net/if.c
 +++ b/sys/net/if.c
 @@ -2021,6 +2021,8 @@ p2p_rtrequest(int req, struct rtentry *rt,
                 if ((rt->rt_flags & RTF_LOCAL) == 0)
                         break;

 +               rt->rt_ifp = lo0ifp;
 +
                 IFADDR_FOREACH(ifa, ifp) {
                         if (equal(rt_getkey(rt), ifa->ifa_addr))
                                 break;
 @@ -2039,8 +2041,6 @@ p2p_rtrequest(int req, struct rtentry *rt,
                 if (lo0ifa == NULL)
                         break;

 -               rt->rt_ifp = lo0ifp;
 -
                 /*
                  * Make sure to set rt->rt_ifa to the interface
                  * address we are using, otherwise we will have trouble

From: Paul Goyette <paul@whooppee.com>
To: Ryota Ozaki <ozaki-r@netbsd.org>
Cc: "gnats-bugs@NetBSD.org" <gnats-bugs@netbsd.org>
Subject: Re: kern/51301: 7.99.32 has broken IPv6 functionality of pkgsrc/net/openvpn
Date: Sun, 3 Jul 2016 06:44:05 +0800 (PHT)

 On Sat, 2 Jul 2016, Ryota Ozaki wrote:

 > Does the following patch help you?
 >
 > Thanks,
 >  ozaki-r
 >
 > diff --git a/sys/net/if.c b/sys/net/if.c
 > index dc73c47..62e58c8 100644
 > --- a/sys/net/if.c
 > +++ b/sys/net/if.c
 > @@ -2021,6 +2021,8 @@ p2p_rtrequest(int req, struct rtentry *rt,
 >                if ((rt->rt_flags & RTF_LOCAL) == 0)
 >                        break;
 >
 > +               rt->rt_ifp = lo0ifp;
 > +
 >                IFADDR_FOREACH(ifa, ifp) {
 >                        if (equal(rt_getkey(rt), ifa->ifa_addr))
 >                                break;
 > @@ -2039,8 +2041,6 @@ p2p_rtrequest(int req, struct rtentry *rt,
 >                if (lo0ifa == NULL)
 >                        break;
 >
 > -               rt->rt_ifp = lo0ifp;
 > -
 >                /*
 >                 * Make sure to set rt->rt_ifa to the interface
 >                 * address we are using, otherwise we will have trouble

 Yes!

 A kernel built from today's up-to-the-minute sources and with this patch 
 works successfully.



 +------------------+--------------------------+------------------------+
 | Paul Goyette     | PGP Key fingerprint:     | E-mail addresses:      |
 | (Retired)        | FA29 0E3B 35AF E8AE 6651 | paul at whooppee.com   |
 | Kernel Developer | 0786 F758 55DE 53BA 7731 | pgoyette at netbsd.org |
 +------------------+--------------------------+------------------------+

From: Ryota Ozaki <ozaki-r@netbsd.org>
To: Paul Goyette <paul@whooppee.com>
Cc: "gnats-bugs@NetBSD.org" <gnats-bugs@netbsd.org>
Subject: Re: kern/51301: 7.99.32 has broken IPv6 functionality of pkgsrc/net/openvpn
Date: Sun, 3 Jul 2016 14:10:29 +0900

 On Sun, Jul 3, 2016 at 7:44 AM, Paul Goyette <paul@whooppee.com> wrote:
 > On Sat, 2 Jul 2016, Ryota Ozaki wrote:
 >
 >> Does the following patch help you?
 >>
 >> Thanks,
 >>  ozaki-r
 >>
 >> diff --git a/sys/net/if.c b/sys/net/if.c
 >> index dc73c47..62e58c8 100644
 >> --- a/sys/net/if.c
 >> +++ b/sys/net/if.c
 >> @@ -2021,6 +2021,8 @@ p2p_rtrequest(int req, struct rtentry *rt,
 >>                if ((rt->rt_flags & RTF_LOCAL) == 0)
 >>                        break;
 >>
 >> +               rt->rt_ifp = lo0ifp;
 >> +
 >>                IFADDR_FOREACH(ifa, ifp) {
 >>                        if (equal(rt_getkey(rt), ifa->ifa_addr))
 >>                                break;
 >> @@ -2039,8 +2041,6 @@ p2p_rtrequest(int req, struct rtentry *rt,
 >>                if (lo0ifa == NULL)
 >>                        break;
 >>
 >> -               rt->rt_ifp = lo0ifp;
 >> -
 >>                /*
 >>                 * Make sure to set rt->rt_ifa to the interface
 >>                 * address we are using, otherwise we will have trouble
 >
 >
 > Yes!
 >
 > A kernel built from today's up-to-the-minute sources and with this patch
 > works successfully.

 Good! Thanks for testing.

 I'll investigate more Monday and commit the fix if it's really feasible.

   ozaki-r

From: "Ryota Ozaki" <ozaki-r@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/51301 CVS commit: src/sys/net
Date: Mon, 4 Jul 2016 01:36:06 +0000

 Module Name:	src
 Committed By:	ozaki-r
 Date:		Mon Jul  4 01:36:06 UTC 2016

 Modified Files:
 	src/sys/net: if.c

 Log Message:
 Tweak p2p_rtrequest as well for ifaddr initialization change

 We need to set lo0ifp to rt->rt_ifp if the interface is RTF_LOCAL.

 Fix PR kern/51301.


 To generate a diff of this commit:
 cvs rdiff -u -r1.350 -r1.351 src/sys/net/if.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->closed
State-Changed-By: ozaki-r@NetBSD.org
State-Changed-When: Tue, 05 Jul 2016 02:18:54 +0000
State-Changed-Why:
The report confirmed the issue is fixed.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2014 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.