inet: reduce silent packet discards
This commit is contained in:
parent
1595f74976
commit
d511e529cc
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ip_input.c,v 1.396 2020/08/28 06:30:08 ozaki-r Exp $ */
|
||||
/* $NetBSD: ip_input.c,v 1.397 2020/08/28 06:31:42 ozaki-r Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
|
||||
@ -91,7 +91,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: ip_input.c,v 1.396 2020/08/28 06:30:08 ozaki-r Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ip_input.c,v 1.397 2020/08/28 06:31:42 ozaki-r Exp $");
|
||||
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_inet.h"
|
||||
@ -404,6 +404,7 @@ ipintr(void *arg __unused)
|
||||
|
||||
ifp = m_get_rcvif_psref(m, &psref);
|
||||
if (__predict_false(ifp == NULL)) {
|
||||
IP_STATINC(IP_STAT_IFDROP);
|
||||
m_freem(m);
|
||||
continue;
|
||||
}
|
||||
@ -440,8 +441,11 @@ ip_input(struct mbuf *m, struct ifnet *ifp)
|
||||
* are receiving, can't do anything with incoming packets yet.
|
||||
* Note: we pre-check without locks held.
|
||||
*/
|
||||
if (IN_ADDRLIST_READER_EMPTY())
|
||||
if (IN_ADDRLIST_READER_EMPTY()) {
|
||||
IP_STATINC(IP_STAT_IFDROP);
|
||||
goto out;
|
||||
}
|
||||
|
||||
IP_STATINC(IP_STAT_TOTAL);
|
||||
|
||||
/*
|
||||
@ -1363,6 +1367,7 @@ ip_forward(struct mbuf *m, int srcrt, struct ifnet *rcvif)
|
||||
}
|
||||
|
||||
if (ip->ip_ttl <= IPTTLDEC) {
|
||||
IP_STATINC(IP_STAT_TIMXCEED);
|
||||
icmp_error(m, ICMP_TIMXCEED, ICMP_TIMXCEED_INTRANS, dest, 0);
|
||||
return;
|
||||
}
|
||||
@ -1373,6 +1378,7 @@ ip_forward(struct mbuf *m, int srcrt, struct ifnet *rcvif)
|
||||
rt = rtcache_lookup(ro, &u.dst);
|
||||
if (rt == NULL) {
|
||||
rtcache_percpu_putref(ipforward_rt_percpu);
|
||||
IP_STATINC(IP_STAT_NOROUTE);
|
||||
icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_NET, dest, 0);
|
||||
return;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ip_output.c,v 1.317 2020/08/28 06:22:25 ozaki-r Exp $ */
|
||||
/* $NetBSD: ip_output.c,v 1.318 2020/08/28 06:31:42 ozaki-r Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
|
||||
@ -91,7 +91,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: ip_output.c,v 1.317 2020/08/28 06:22:25 ozaki-r Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ip_output.c,v 1.318 2020/08/28 06:31:42 ozaki-r Exp $");
|
||||
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_inet.h"
|
||||
@ -202,6 +202,7 @@ ip_if_output(struct ifnet * const ifp, struct mbuf * const m,
|
||||
if (rt != NULL) {
|
||||
error = rt_check_reject_route(rt, ifp);
|
||||
if (error != 0) {
|
||||
IP_STATINC(IP_STAT_RTREJECT);
|
||||
m_freem(m);
|
||||
return error;
|
||||
}
|
||||
@ -312,8 +313,10 @@ ip_output(struct mbuf *m0, struct mbuf *opt, struct route *ro, int flags,
|
||||
(rt = rtcache_update(ro, 1)) == NULL) {
|
||||
dst = &udst.sin;
|
||||
error = rtcache_setdst(ro, &udst.sa);
|
||||
if (error != 0)
|
||||
if (error != 0) {
|
||||
IP_STATINC(IP_STAT_ODROPPED);
|
||||
goto bad;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@ -346,6 +349,7 @@ ip_output(struct mbuf *m0, struct mbuf *opt, struct route *ro, int flags,
|
||||
mtu = ifp->if_mtu;
|
||||
ia = in_get_ia_from_ifp_psref(ifp, &psref_ia);
|
||||
if (ia == NULL) {
|
||||
IP_STATINC(IP_STAT_IFNOADDR);
|
||||
error = EADDRNOTAVAIL;
|
||||
goto bad;
|
||||
}
|
||||
@ -451,6 +455,7 @@ ip_output(struct mbuf *m0, struct mbuf *opt, struct route *ro, int flags,
|
||||
|
||||
xia = in_get_ia_from_ifp_psref(ifp, &_psref);
|
||||
if (!xia) {
|
||||
IP_STATINC(IP_STAT_IFNOADDR);
|
||||
error = EADDRNOTAVAIL;
|
||||
goto bad;
|
||||
}
|
||||
@ -460,6 +465,7 @@ ip_output(struct mbuf *m0, struct mbuf *opt, struct route *ro, int flags,
|
||||
/* FIXME ifa_getifa is NOMPSAFE */
|
||||
xia = ifatoia((*xifa->ifa_getifa)(xifa, rdst));
|
||||
if (xia == NULL) {
|
||||
IP_STATINC(IP_STAT_IFNOADDR);
|
||||
error = EADDRNOTAVAIL;
|
||||
goto bad;
|
||||
}
|
||||
@ -511,6 +517,7 @@ ip_output(struct mbuf *m0, struct mbuf *opt, struct route *ro, int flags,
|
||||
* destination group on the loopback interface.
|
||||
*/
|
||||
if (ip->ip_ttl == 0 || (ifp->if_flags & IFF_LOOPBACK) != 0) {
|
||||
IP_STATINC(IP_STAT_ODROPPED);
|
||||
m_freem(m);
|
||||
goto done;
|
||||
}
|
||||
@ -554,15 +561,18 @@ ip_output(struct mbuf *m0, struct mbuf *opt, struct route *ro, int flags,
|
||||
*/
|
||||
if (isbroadcast) {
|
||||
if ((ifp->if_flags & IFF_BROADCAST) == 0) {
|
||||
IP_STATINC(IP_STAT_BCASTDENIED);
|
||||
error = EADDRNOTAVAIL;
|
||||
goto bad;
|
||||
}
|
||||
if ((flags & IP_ALLOWBROADCAST) == 0) {
|
||||
IP_STATINC(IP_STAT_BCASTDENIED);
|
||||
error = EACCES;
|
||||
goto bad;
|
||||
}
|
||||
/* don't allow broadcast messages to be fragmented */
|
||||
if (ntohs(ip->ip_len) > ifp->if_mtu) {
|
||||
IP_STATINC(IP_STAT_BCASTDENIED);
|
||||
error = EMSGSIZE;
|
||||
goto bad;
|
||||
}
|
||||
@ -840,6 +850,7 @@ ip_fragment(struct mbuf *m, struct ifnet *ifp, u_long mtu)
|
||||
|
||||
len = (mtu - hlen) &~ 7;
|
||||
if (len < 8) {
|
||||
IP_STATINC(IP_STAT_CANTFRAG);
|
||||
m_freem(m);
|
||||
return EMSGSIZE;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ip_var.h,v 1.129 2020/08/28 06:19:13 ozaki-r Exp $ */
|
||||
/* $NetBSD: ip_var.h,v 1.130 2020/08/28 06:31:42 ozaki-r Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 1993
|
||||
@ -151,8 +151,13 @@ struct ip_pktopts {
|
||||
#define IP_STAT_PFILDROP_OUT 33 /* dropped by pfil (PFIL_OUT) */
|
||||
#define IP_STAT_IPSECDROP_IN 34 /* dropped by IPsec SP check */
|
||||
#define IP_STAT_IPSECDROP_OUT 35 /* dropped by IPsec SP check */
|
||||
#define IP_STAT_IFDROP 36 /* dropped due to interface state */
|
||||
#define IP_STAT_TIMXCEED 37 /* time to live exceeded */
|
||||
#define IP_STAT_IFNOADDR 38 /* interface has no IP address */
|
||||
#define IP_STAT_RTREJECT 39 /* rejected by route */
|
||||
#define IP_STAT_BCASTDENIED 40 /* broadcast prohibited */
|
||||
|
||||
#define IP_NSTATS 36
|
||||
#define IP_NSTATS 41
|
||||
|
||||
#ifdef _KERNEL
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user