net: unify mtu update code

Subscribers: imp, ae, glebius

Differential Revision: https://reviews.freebsd.org/D38893
This commit is contained in:
Alexander V. Chernikov 2023-03-03 16:30:15 +00:00
parent 062f2818c1
commit 66bdbcd544
5 changed files with 18 additions and 48 deletions

View File

@ -2853,12 +2853,8 @@ ifhwioctl(u_long cmd, struct ifnet *ifp, caddr_t data, struct thread *td)
/*
* If the link MTU changed, do network layer specific procedure.
*/
if (ifp->if_mtu != oldmtu) {
#ifdef INET6
nd6_setmtu(ifp);
#endif
rt_updatemtu(ifp);
}
if (ifp->if_mtu != oldmtu)
if_notifymtu(ifp);
break;
}
@ -4470,6 +4466,15 @@ if_setmtu(if_t ifp, int mtu)
return (0);
}
void
if_notifymtu(if_t ifp)
{
#ifdef INET6
nd6_setmtu(ifp);
#endif
rt_updatemtu(ifp);
}
int
if_getmtu(const if_t ifp)
{

View File

@ -136,14 +136,6 @@ __FBSDID("$FreeBSD$");
#include <net/route.h>
#ifdef INET6
/*
* XXX: declare here to avoid to include many inet6 related files..
* should be more generalized?
*/
extern void nd6_setmtu(struct ifnet *);
#endif
/*
* Size of the route hash table. Must be a power of two.
*/
@ -910,12 +902,8 @@ bridge_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
* Bridge MTU may change during addition of the first port.
* If it did, do network layer specific procedure.
*/
if (ifp->if_mtu != oldmtu) {
#ifdef INET6
nd6_setmtu(ifp);
#endif
rt_updatemtu(ifp);
}
if (ifp->if_mtu != oldmtu)
if_notifymtu(ifp);
if (bc->bc_flags & BC_F_COPYOUT)
error = copyout(&args, ifd->ifd_data, ifd->ifd_len);

View File

@ -77,14 +77,6 @@ __FBSDID("$FreeBSD$");
#include <net/if_lagg.h>
#include <net/ieee8023ad_lacp.h>
#ifdef INET6
/*
* XXX: declare here to avoid to include many inet6 related files..
* should be more generalized?
*/
extern void nd6_setmtu(struct ifnet *);
#endif
#ifdef DEV_NETMAP
MODULE_DEPEND(if_lagg, netmap, 1, 1, 1);
#endif
@ -1636,12 +1628,8 @@ lagg_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
* LAGG MTU may change during addition of the first port.
* If it did, do network layer specific procedure.
*/
if (ifp->if_mtu != oldmtu) {
#ifdef INET6
nd6_setmtu(ifp);
#endif
rt_updatemtu(ifp);
}
if (ifp->if_mtu != oldmtu)
if_notifymtu(ifp);
VLAN_CAPABILITIES(ifp);
break;

View File

@ -618,6 +618,7 @@ 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);
int if_setflagbits(if_t ifp, int set, int clear);
int if_setflags(if_t ifp, int flags);
int if_getflags(const if_t ifp);

View File

@ -85,14 +85,6 @@ __FBSDID("$FreeBSD$");
#include <netinet/if_ether.h>
#endif
#ifdef INET6
/*
* XXX: declare here to avoid to include many inet6 related files..
* should be more generalized?
*/
extern void nd6_setmtu(struct ifnet *);
#endif
#define VLAN_DEF_HWIDTH 4
#define VLAN_IFFLAGS (IFF_BROADCAST | IFF_MULTICAST)
@ -2110,12 +2102,8 @@ vlan_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
* VLAN MTU may change during addition of the vlandev.
* If it did, do network layer specific procedure.
*/
if (ifp->if_mtu != oldmtu) {
#ifdef INET6
nd6_setmtu(ifp);
#endif
rt_updatemtu(ifp);
}
if (ifp->if_mtu != oldmtu)
if_notifymtu(ifp);
break;
case SIOCGETVLAN: