Bug 223129 - Addition of an IP address to an interface (SIOCAIFADDR) fails when there is conflicting dynamic route
Summary: Addition of an IP address to an interface (SIOCAIFADDR) fails when there is c...
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 11.0-STABLE
Hardware: Any Any
: --- Affects Some People
Assignee: Eugene Grosbein
URL:
Keywords: easy, patch-ready
Depends on:
Blocks:
 
Reported: 2017-10-20 14:10 UTC by Eugene Grosbein
Modified: 2021-06-03 18:30 UTC (History)
1 user (show)

See Also:


Attachments
proposed fix (994 bytes, patch)
2017-10-20 20:42 UTC, Eugene Grosbein
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Eugene Grosbein freebsd_committer freebsd_triage 2017-10-20 14:10:51 UTC
Hi!

I have a router that nearly simultaneously creates two netgraph-based PPP VPN tunnels (ng_iface ngX) to the same remote router and establishes OSPF neighbourship over each tunnel to announce and receive some prefixes.

It repeatedly falls to the same problem. Here is a scenario:

1. First PPP tunnel is created by first router and addresses are assigned: 192.168.71.9 for itself and 192.168.71.10 for second router. Addresses then accepted and successfully assigned by second router.

2. Second PPP tunnel is created and again, first router assignes addresses 192.168.71.13 for itself and 192.168.71.14 for part of the tunnel. First router announces 192.168.71.14/32 using OSPF over first tunnel and second router's ospfd process installs this route to the kernel using 192.168.71.9 as gateway:

got message of size 184 on Fri Oct 20 14:54:15 2017
RTM_ADD: Add Route: len 184, pid: 90850, seq 44, errno 0, flags:<UP,GATEWAY,HOST,DONE,PROTO1>
locks:  inits: 
sockaddrs: <DST,GATEWAY>
 192.168.71.14 192.168.71.9

3. Second router'd PPP daemon attempts to assign negotiated addresses 192.168.71.14 and 192.168.71.13 to the second ng_iface being configured with ioctl(SIOCAIFADDR):

got message of size 164 on Fri Oct 20 16:04:59 2017
RTM_NEWADDR: address being added to iface: len 164, metric 0, flags:
sockaddrs: <NETMASK,IFP,IFA,BRD>
  ng2 192.168.71.14 192.168.71.13

got message of size 224 on Fri Oct 20 16:04:59 2017
RTM_ADD: Add Route: len 224, pid: 0, seq 0, errno 0, flags:<UP,HOST,PINNED>
locks:  inits: 
sockaddrs: <DST,GATEWAY>
 192.168.71.13 link#9

But kernel returns an error EEXIST (17) and writes to the log:

kernel: ifa_maintain_loopback_route: insertion failed for interface ng2: 17

The kernel should allow PPP daemon (net/mpd5 in this case) to override dynamic route with PINNED address assignment.
Comment 1 Eugene Grosbein freebsd_committer freebsd_triage 2017-10-20 20:42:23 UTC
Created attachment 187334 [details]
proposed fix
Comment 2 Eugene Grosbein freebsd_committer freebsd_triage 2017-10-20 20:44:47 UTC
Proposed one-line patch fixes the problem for me.
Comment 3 commit-hook freebsd_committer freebsd_triage 2017-11-05 14:42:21 UTC
A commit references this bug:

Author: eugen
Date: Sun Nov  5 14:41:49 UTC 2017
New revision: 325436
URL: https://svnweb.freebsd.org/changeset/base/325436

Log:
  Allow a process to assign an IP address to local ppp interface
  even if kernel routing table already has a route to the address in question
  installed by some routing daemon (PR 223129).

  Also, allow loopback route deletion when stopping a VIMAGE jail (PR 222647).

  PR:			222647, 223129
  Reviewed by:		gnn
  Approved by:		avg (mentor), mav (mentor)
  MFC after:		2 weeks
  Differential Revision:	https://reviews.freebsd.org/D12747

Changes:
  head/sys/net/if.c
Comment 4 commit-hook freebsd_committer freebsd_triage 2017-11-20 09:24:05 UTC
A commit references this bug:

Author: eugen
Date: Mon Nov 20 09:23:09 UTC 2017
New revision: 326011
URL: https://svnweb.freebsd.org/changeset/base/326011

Log:
  MFC r325436: RTF_PINNED for an interface

    Allow a process to assign an IP address to local ppp interface
    even if kernel routing table already has a route to the address in question
    installed by some routing daemon (PR 223129).

    Also, allow loopback route deletion when stopping a VIMAGE jail (PR 222647).

  PR:			222647, 223129
  Reviewed by:		gnn
  Approved by:		mav (mentor)
  Differential Revision:	https://reviews.freebsd.org/D12747

Changes:
_U  stable/11/
  stable/11/sys/net/if.c
Comment 5 commit-hook freebsd_committer freebsd_triage 2017-11-20 09:25:10 UTC
A commit references this bug:

Author: eugen
Date: Mon Nov 20 09:24:02 UTC 2017
New revision: 326012
URL: https://svnweb.freebsd.org/changeset/base/326012

Log:
  MFC r325436: RTF_PINNED for an interface

    Allow a process to assign an IP address to local ppp interface
    even if kernel routing table already has a route to the address in question
    installed by some routing daemon (PR 223129).

    Also, allow loopback route deletion when stopping a VIMAGE jail (PR 222647).

  PR:			222647, 223129
  Reviewed by:		gnn
  Approved by:		mav (mentor)
  Differential Revision:	https://reviews.freebsd.org/D12747

Changes:
_U  stable/10/
  stable/10/sys/net/if.c
Comment 6 Eugene Grosbein freebsd_committer freebsd_triage 2017-11-20 10:44:20 UTC
Fixed with r325436 and MFC r326011, r326012.