Bug 277125 - ifconfig: ioctl (SIOCAIFADDR): File exists when P2P dest_addr route exists
Summary: ifconfig: ioctl (SIOCAIFADDR): File exists when P2P dest_addr route exists
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 13.2-RELEASE
Hardware: Any Any
: --- Affects Only Me
Assignee: Alexander V. Chernikov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-02-18 03:04 UTC by Oleksandr Ignatyev
Modified: 2025-01-11 12:37 UTC (History)
6 users (show)

See Also:
eugen: mfc-stable14+
eugen: mfc-stable13+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Oleksandr Ignatyev 2024-02-18 03:04:54 UTC
Making backup GRE link and getting destination IP address from another link (OSPF, bird2, frr).

# ifconfig gre3
gre3: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> metric 0 mtu 1500
        options=80000<LINKSTATE>
        tunnel inet 10.8.98.3 --> 10.8.98.1
        groups: gre
        nd6 options=9<PERFORMNUD,IFDISABLED>

# route get 10.8.34.65/30
   route to: 10.8.34.65
destination: 10.8.34.64
       mask: 255.255.255.252
    gateway: 10.8.34.2
        fib: 0
  interface: ipsec0
      flags: <UP,GATEWAY,DONE,PROTO1>
 recvpipe  sendpipe  ssthresh  rtt,msec    mtu        weight    expire
       0         0         0         0      1500         1         0

# route get 10.8.34.66
   route to: 10.8.34.66
destination: 10.8.34.66
    gateway: 10.8.34.2
        fib: 0
  interface: ipsec0
      flags: <UP,GATEWAY,HOST,DONE,PROTO1>
 recvpipe  sendpipe  ssthresh  rtt,msec    mtu        weight    expire
       0         0         0         0      1500         1         0

# ifconfig gre3 10.8.34.65/30 10.8.34.66
ifconfig: ioctl (SIOCAIFADDR): File exists


It works properly here
# route delete 10.8.34.66 && ifconfig gre3 10.8.34.65/30 10.8.34.66 && echo ok
delete host 10.8.34.66
ok


and here, when another IP from /30 is used
#ifconfig gre3 10.8.34.65/30 10.8.34.67 && echo ok
ok

# uname -a | blur
FreeBSD ... 13.2-RELEASE-p10 FreeBSD 13.2-RELEASE-p10 GENERIC amd64

Expecting local assignments should have more priority.
Didn't tried with another FreeBSD release, but 13.2 is affected.
Comment 1 Jose Luis Duran freebsd_committer freebsd_triage 2024-11-04 03:17:09 UTC
A shorter way to reproduce it:

    # route add -net 192.0.2.0/24 -interface vtnet0
    add net 192.0.2.0: gateway vtnet0
    # ifconfig epair create
    epair0a
    # ifconfig epair0a inet 192.0.2.1/24
    ifconfig: ioctl (SIOCAIFADDR): File exists

I'm also not used to first having to delete the route in order to assign an address that's already in the routing table.
Comment 2 Alexander V. Chernikov freebsd_committer freebsd_triage 2024-11-12 21:48:14 UTC
Please see https://reviews.freebsd.org/D47534 that should fix this one.
Comment 3 Jose Luis Duran freebsd_committer freebsd_triage 2024-11-13 04:55:04 UTC
(In reply to Alexander V. Chernikov from comment #2)
Amazing!
Comment 4 commit-hook freebsd_committer freebsd_triage 2024-11-13 21:04:56 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=1da4954c92ea7585b352ba830d3ee64ca69ada52

commit 1da4954c92ea7585b352ba830d3ee64ca69ada52
Author:     Alexander V. Chernikov <melifaro@FreeBSD.org>
AuthorDate: 2024-11-12 23:36:50 +0000
Commit:     Alexander V. Chernikov <melifaro@FreeBSD.org>
CommitDate: 2024-11-12 23:36:50 +0000

    Fix failure to add an interface prefix route when route with the same
     prefix is already presented in the routing table.

    PR:             277125
    Reported by:    Oleksandr Ignatyev <alex@i.org.ua>
    Reviewed by:    ae, jlduran
    Tested by:      jlduran
    Differential Revision: https://reviews.freebsd.org/D47534
    MFC after:      2 weeks

 sys/net/route/route_ctl.c | 13 ++++++++-----
 sys/net/route/route_ctl.h | 10 +++++-----
 2 files changed, 13 insertions(+), 10 deletions(-)
Comment 5 commit-hook freebsd_committer freebsd_triage 2025-01-11 12:28:20 UTC
A commit in branch stable/14 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=d62b2d8f3a4711724d984102daa0bd0a5351f8b9

commit d62b2d8f3a4711724d984102daa0bd0a5351f8b9
Author:     Alexander V. Chernikov <melifaro@FreeBSD.org>
AuthorDate: 2024-11-12 23:36:50 +0000
Commit:     Eugene Grosbein <eugen@FreeBSD.org>
CommitDate: 2025-01-11 12:25:16 +0000

    Fix failure to add an interface prefix route
    when route with the same prefix is already presented
    in the routing table.

    PR:             277125
    Reported by:    Oleksandr Ignatyev <alex@i.org.ua>
    Reviewed by:    ae, jlduran
    Tested by:      jlduran
    Differential Revision: https://reviews.freebsd.org/D47534

    (cherry picked from commit 1da4954c92ea7585b352ba830d3ee64ca69ada52)

 sys/net/route/route_ctl.c | 13 ++++++++-----
 sys/net/route/route_ctl.h | 10 +++++-----
 2 files changed, 13 insertions(+), 10 deletions(-)
Comment 6 commit-hook freebsd_committer freebsd_triage 2025-01-11 12:36:24 UTC
A commit in branch stable/13 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=f57df4589d3cd91dac88b2c9edb80ad0eb50979c

commit f57df4589d3cd91dac88b2c9edb80ad0eb50979c
Author:     Alexander V. Chernikov <melifaro@FreeBSD.org>
AuthorDate: 2024-11-12 23:36:50 +0000
Commit:     Eugene Grosbein <eugen@FreeBSD.org>
CommitDate: 2025-01-11 12:34:48 +0000

    Fix failure to add an interface prefix route
    when route with the same  prefix is already presented
    in the routing table.

    PR:             277125
    Reported by:    Oleksandr Ignatyev <alex@i.org.ua>
    Reviewed by:    ae, jlduran
    Tested by:      jlduran
    Differential Revision: https://reviews.freebsd.org/D47534

    (cherry picked from commit 1da4954c92ea7585b352ba830d3ee64ca69ada52)

 sys/net/route/route_ctl.c | 13 ++++++++-----
 sys/net/route/route_ctl.h | 10 +++++-----
 2 files changed, 13 insertions(+), 10 deletions(-)