netinet6: use in6_ifmtu() instead of IN6_LINKMTU() macro
There should be no functional change. If there are any performance concerns with a function call, with the future changes, that would move ND6 bits into in6_ifextra, this function would be easily inline-able. Reviewed by: tuexen Differential Revision: https://reviews.freebsd.org/D54724
This commit is contained in:
+7
-2
@@ -2627,9 +2627,14 @@ EVENTHANDLER_DEFINE(ifnet_arrival_event, in6_ifarrival, NULL,
|
||||
EVENTHANDLER_PRI_ANY);
|
||||
|
||||
uint32_t
|
||||
in6_ifmtu(struct ifnet *ifp)
|
||||
in6_ifmtu(const struct ifnet *ifp)
|
||||
{
|
||||
return (IN6_LINKMTU(ifp));
|
||||
struct nd_ifinfo *ndi = ND_IFINFO(ifp);
|
||||
|
||||
return (
|
||||
(ndi->linkmtu > 0 && ndi->linkmtu < ifp->if_mtu) ? ndi->linkmtu :
|
||||
((ndi->maxmtu > 0 && ndi->maxmtu < ifp->if_mtu) ? ndi->maxmtu :
|
||||
ifp->if_mtu));
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -114,10 +114,8 @@ rib6_augment_nh(u_int fibnum, struct nhop_object *nh)
|
||||
* inherit interface MTU if not set or
|
||||
* check if MTU is too large.
|
||||
*/
|
||||
if (nh->nh_mtu == 0) {
|
||||
nh->nh_mtu = IN6_LINKMTU(nh->nh_ifp);
|
||||
} else if (nh->nh_mtu > IN6_LINKMTU(nh->nh_ifp))
|
||||
nh->nh_mtu = IN6_LINKMTU(nh->nh_ifp);
|
||||
if (nh->nh_mtu == 0 || nh->nh_mtu > in6_ifmtu(nh->nh_ifp))
|
||||
nh->nh_mtu = in6_ifmtu(nh->nh_ifp);
|
||||
|
||||
/* Set nexthop type */
|
||||
if (nhop_get_type(nh) == 0) {
|
||||
|
||||
@@ -861,7 +861,7 @@ void in6_purgeaddr(struct ifaddr *);
|
||||
void in6_purgeifaddr(struct in6_ifaddr *);
|
||||
int in6if_do_dad(struct ifnet *);
|
||||
void in6_savemkludge(struct in6_ifaddr *);
|
||||
uint32_t in6_ifmtu(struct ifnet *);
|
||||
uint32_t in6_ifmtu(const struct ifnet *);
|
||||
struct rib_head *in6_inithead(uint32_t fibnum);
|
||||
void in6_detachhead(struct rib_head *rh);
|
||||
int in6_if2idlen(struct ifnet *);
|
||||
|
||||
@@ -384,11 +384,11 @@ ip6_forward(struct mbuf *m, int srcrt)
|
||||
pass:
|
||||
/* See if the size was changed by the packet filter. */
|
||||
/* TODO: change to nh->nh_mtu */
|
||||
if (m->m_pkthdr.len > IN6_LINKMTU(nh->nh_ifp)) {
|
||||
if (m->m_pkthdr.len > in6_ifmtu(nh->nh_ifp)) {
|
||||
in6_ifstat_inc(nh->nh_ifp, ifs6_in_toobig);
|
||||
if (mcopy)
|
||||
icmp6_error(mcopy, ICMP6_PACKET_TOO_BIG, 0,
|
||||
IN6_LINKMTU(nh->nh_ifp));
|
||||
in6_ifmtu(nh->nh_ifp));
|
||||
goto bad;
|
||||
}
|
||||
|
||||
|
||||
@@ -1582,7 +1582,7 @@ phyint_send(struct ip6_hdr *ip6, struct mif6 *mifp, struct mbuf *m)
|
||||
* Put the packet into the sending queue of the outgoing interface
|
||||
* if it would fit in the MTU of the interface.
|
||||
*/
|
||||
linkmtu = IN6_LINKMTU(ifp);
|
||||
linkmtu = in6_ifmtu(ifp);
|
||||
if (mb_copy->m_pkthdr.len <= linkmtu || linkmtu < IPV6_MMTU) {
|
||||
struct sockaddr_in6 dst6;
|
||||
|
||||
|
||||
@@ -1147,7 +1147,7 @@ ip6_output(struct mbuf *m0, struct ip6_pktopts *opt,
|
||||
dontfrag = 1;
|
||||
else
|
||||
dontfrag = 0;
|
||||
if (dontfrag && tlen > IN6_LINKMTU(ifp) && !tso) { /* Case 2-b. */
|
||||
if (dontfrag && tlen > in6_ifmtu(ifp) && !tso) { /* Case 2-b. */
|
||||
/*
|
||||
* If the DONTFRAG option is specified, we cannot send the
|
||||
* packet when the data length is larger than the MTU of the
|
||||
@@ -1561,7 +1561,7 @@ ip6_calcmtu(struct ifnet *ifp, const struct in6_addr *dst, u_long rt_mtu,
|
||||
}
|
||||
|
||||
if (mtu == 0)
|
||||
mtu = IN6_LINKMTU(ifp);
|
||||
mtu = in6_ifmtu(ifp);
|
||||
|
||||
*mtup = mtu;
|
||||
}
|
||||
|
||||
+1
-1
@@ -1662,7 +1662,7 @@ nd6_ioctl(u_long cmd, caddr_t data, struct ifnet *ifp)
|
||||
/* 0 means 'unspecified' */
|
||||
if (ND.linkmtu != 0) {
|
||||
if (ND.linkmtu < IPV6_MMTU ||
|
||||
ND.linkmtu > IN6_LINKMTU(ifp)) {
|
||||
ND.linkmtu > in6_ifmtu(ifp)) {
|
||||
error = EINVAL;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -83,11 +83,6 @@ struct llentry;
|
||||
|
||||
#ifdef _KERNEL
|
||||
#define ND_IFINFO(ifp) ((if_getinet6(ifp))->nd_ifinfo)
|
||||
#define IN6_LINKMTU(ifp) \
|
||||
((ND_IFINFO(ifp)->linkmtu && ND_IFINFO(ifp)->linkmtu < (ifp)->if_mtu) \
|
||||
? ND_IFINFO(ifp)->linkmtu \
|
||||
: ((ND_IFINFO(ifp)->maxmtu && ND_IFINFO(ifp)->maxmtu < (ifp)->if_mtu) \
|
||||
? ND_IFINFO(ifp)->maxmtu : (ifp)->if_mtu))
|
||||
#endif
|
||||
|
||||
struct in6_nbrinfo {
|
||||
|
||||
+2
-2
@@ -11708,9 +11708,9 @@ pf_test(sa_family_t af, int dir, int pflags, struct ifnet *ifp, struct mbuf **m0
|
||||
* it here, before we do any NAT.
|
||||
*/
|
||||
if (af == AF_INET6 && dir == PF_OUT && pflags & PFIL_FWD &&
|
||||
IN6_LINKMTU(ifp) < pf_max_frag_size(*m0)) {
|
||||
in6_ifmtu(ifp) < pf_max_frag_size(*m0)) {
|
||||
PF_RULES_RUNLOCK();
|
||||
icmp6_error(*m0, ICMP6_PACKET_TOO_BIG, 0, IN6_LINKMTU(ifp));
|
||||
icmp6_error(*m0, ICMP6_PACKET_TOO_BIG, 0, in6_ifmtu(ifp));
|
||||
*m0 = NULL;
|
||||
return (PF_DROP);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user