The branch main has been updated by glebius:

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

commit fd131b47f20dbeb515f5e3e6ea87948f2638eda9
Author:     Gleb Smirnoff <[email protected]>
AuthorDate: 2025-12-04 19:14:34 +0000
Commit:     Gleb Smirnoff <[email protected]>
CommitDate: 2025-12-04 19:16:25 +0000

    net: remove dom_ifmtu
    
    It is a remnant of a network stack design that was supposed to support
    multiple network protocols.  Today it is clear that we are left with IPv4
    and IPv6 only.  Only IPv6 may have an MTU different to the interface MTU.
---
 sys/net/if.c             | 13 -------------
 sys/net/if_var.h         |  1 -
 sys/net/route.c          | 33 ++++++++++++++++++---------------
 sys/netinet6/in6.c       |  7 ++-----
 sys/netinet6/in6_proto.c |  1 -
 sys/netinet6/in6_var.h   |  2 +-
 sys/sys/domain.h         |  2 --
 7 files changed, 21 insertions(+), 38 deletions(-)

diff --git a/sys/net/if.c b/sys/net/if.c
index cb9c47c14c32..f5006781541c 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -4467,19 +4467,6 @@ if_getmtu(const if_t ifp)
        return (ifp->if_mtu);
 }
 
-int
-if_getmtu_family(const if_t ifp, int family)
-{
-       struct domain *dp;
-
-       SLIST_FOREACH(dp, &domains, dom_next) {
-               if (dp->dom_family == family && dp->dom_ifmtu != NULL)
-                       return (dp->dom_ifmtu(ifp));
-       }
-
-       return (ifp->if_mtu);
-}
-
 void
 if_setppromisc(if_t ifp, bool ppromisc)
 {
diff --git a/sys/net/if_var.h b/sys/net/if_var.h
index 961259bb0ca1..b717e879815b 100644
--- a/sys/net/if_var.h
+++ b/sys/net/if_var.h
@@ -620,7 +620,6 @@ const uint8_t *if_getbroadcastaddr(const if_t ifp);
 void if_setbroadcastaddr(if_t ifp, const uint8_t *);
 int if_setmtu(if_t ifp, int mtu);
 int if_getmtu(const if_t ifp);
-int if_getmtu_family(const if_t ifp, int family);
 void if_notifymtu(if_t ifp);
 void if_setppromisc(const if_t ifp, bool ppromisc);
 int if_setflagbits(if_t ifp, int set, int clear);
diff --git a/sys/net/route.c b/sys/net/route.c
index d2c9f3e39c17..5dbb51a34e56 100644
--- a/sys/net/route.c
+++ b/sys/net/route.c
@@ -508,26 +508,29 @@ rt_getifa_fib(struct rt_addrinfo *info, u_int fibnum)
        return (error);
 }
 
+/*
+ * Try to update rt_mtu for all routes using this interface.  Unfortunately the
+ * only way to do this is to traverse all routing tables in all fibs.
+ */
 void
 rt_updatemtu(struct ifnet *ifp)
 {
        struct rib_head *rnh;
-       int mtu;
-       int i, j;
+#ifdef INET6
+       uint32_t in6mtu;
 
-       /*
-        * Try to update rt_mtu for all routes using this interface
-        * Unfortunately the only way to do this is to traverse all
-        * routing tables in all fibs/domains.
-        */
-       for (i = 1; i <= AF_MAX; i++) {
-               mtu = if_getmtu_family(ifp, i);
-               for (j = 0; j < rt_numfibs; j++) {
-                       rnh = rt_tables_get_rnh(j, i);
-                       if (rnh == NULL)
-                               continue;
-                       nhops_update_ifmtu(rnh, ifp, mtu);
-               }
+       in6mtu = in6_ifmtu(ifp);
+#endif
+
+       for (u_int j = 0; j < rt_numfibs; j++) {
+#ifdef INET
+               rnh = rt_tables_get_rnh(j, AF_INET);
+               nhops_update_ifmtu(rnh, ifp, ifp->if_mtu);
+#endif
+#ifdef INET6
+               rnh = rt_tables_get_rnh(j, AF_INET6);
+               nhops_update_ifmtu(rnh, ifp, in6mtu);
+#endif
        }
 }
 
diff --git a/sys/netinet6/in6.c b/sys/netinet6/in6.c
index f2a032585342..0456ec5decf1 100644
--- a/sys/netinet6/in6.c
+++ b/sys/netinet6/in6.c
@@ -2612,12 +2612,9 @@ in6_domifattach(struct ifnet *ifp)
        return ext;
 }
 
-int
-in6_domifmtu(struct ifnet *ifp)
+uint32_t
+in6_ifmtu(struct ifnet *ifp)
 {
-       if (ifp->if_afdata[AF_INET6] == NULL)
-               return ifp->if_mtu;
-
        return (IN6_LINKMTU(ifp));
 }
 
diff --git a/sys/netinet6/in6_proto.c b/sys/netinet6/in6_proto.c
index a566ca6b0fb0..f3ed72719abf 100644
--- a/sys/netinet6/in6_proto.c
+++ b/sys/netinet6/in6_proto.c
@@ -113,7 +113,6 @@ struct domain inet6domain = {
 #endif
        .dom_ifattach =         in6_domifattach,
        .dom_ifdetach =         in6_domifdetach,
-       .dom_ifmtu    =         in6_domifmtu,
        .dom_nprotosw =         14,
        .dom_protosw = {
                &tcp6_protosw,
diff --git a/sys/netinet6/in6_var.h b/sys/netinet6/in6_var.h
index 1414cc71388d..1210937a5dc4 100644
--- a/sys/netinet6/in6_var.h
+++ b/sys/netinet6/in6_var.h
@@ -869,7 +869,7 @@ int in6if_do_dad(struct ifnet *);
 void   in6_savemkludge(struct in6_ifaddr *);
 void   *in6_domifattach(struct ifnet *);
 void   in6_domifdetach(struct ifnet *, void *);
-int    in6_domifmtu(struct ifnet *);
+uint32_t in6_ifmtu(struct ifnet *);
 struct rib_head *in6_inithead(uint32_t fibnum);
 void   in6_detachhead(struct rib_head *rh);
 int    in6_if2idlen(struct ifnet *);
diff --git a/sys/sys/domain.h b/sys/sys/domain.h
index dfdda1bc9491..5639ef1c01e5 100644
--- a/sys/sys/domain.h
+++ b/sys/sys/domain.h
@@ -58,8 +58,6 @@ struct domain {
                (struct rib_head *);
        void    *(*dom_ifattach)(struct ifnet *);
        void    (*dom_ifdetach)(struct ifnet *, void *);
-       int     (*dom_ifmtu)(struct ifnet *);
-                                       /* af-dependent data on ifnet */
        struct  protosw *dom_protosw[];
 };
 

Reply via email to