aboutsummaryrefslogtreecommitdiff
path: root/sys/net/if_gre.c
diff options
context:
space:
mode:
authorAndrey V. Elsukov <ae@FreeBSD.org>2018-07-09 11:03:28 +0000
committerAndrey V. Elsukov <ae@FreeBSD.org>2018-07-09 11:03:28 +0000
commit98a8fdf6dac8aa5c28a3ac6640a1020bbd7a28da (patch)
treec11f5f87210b66df9470574aa6fc69041276361e /sys/net/if_gre.c
parentd50fbe3fe2e7918d3649eba32c470a0f32e240ce (diff)
downloadsrc-98a8fdf6dac8aa5c28a3ac6640a1020bbd7a28da.tar.gz
src-98a8fdf6dac8aa5c28a3ac6640a1020bbd7a28da.zip
Notes
Diffstat (limited to 'sys/net/if_gre.c')
-rw-r--r--sys/net/if_gre.c34
1 files changed, 3 insertions, 31 deletions
diff --git a/sys/net/if_gre.c b/sys/net/if_gre.c
index aa9672d2bee1..2ef1a35497b2 100644
--- a/sys/net/if_gre.c
+++ b/sys/net/if_gre.c
@@ -503,36 +503,6 @@ drop:
return (IPPROTO_DONE);
}
-#define MTAG_GRE 1307983903
-static int
-gre_check_nesting(struct ifnet *ifp, struct mbuf *m)
-{
- struct m_tag *mtag;
- int count;
-
- count = 1;
- mtag = NULL;
- while ((mtag = m_tag_locate(m, MTAG_GRE, 0, mtag)) != NULL) {
- if (*(struct ifnet **)(mtag + 1) == ifp) {
- log(LOG_NOTICE, "%s: loop detected\n", ifp->if_xname);
- return (EIO);
- }
- count++;
- }
- if (count > V_max_gre_nesting) {
- log(LOG_NOTICE,
- "%s: if_output recursively called too many times(%d)\n",
- ifp->if_xname, count);
- return (EIO);
- }
- mtag = m_tag_alloc(MTAG_GRE, 0, sizeof(struct ifnet *), M_NOWAIT);
- if (mtag == NULL)
- return (ENOMEM);
- *(struct ifnet **)(mtag + 1) = ifp;
- m_tag_prepend(m, mtag);
- return (0);
-}
-
static int
gre_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
struct route *ro)
@@ -569,6 +539,7 @@ gre_setseqn(struct grehdr *gh, uint32_t seq)
*opts = htonl(seq);
}
+#define MTAG_GRE 1307983903
static int
gre_transmit(struct ifnet *ifp, struct mbuf *m)
{
@@ -592,7 +563,8 @@ gre_transmit(struct ifnet *ifp, struct mbuf *m)
if ((ifp->if_flags & IFF_MONITOR) != 0 ||
(ifp->if_flags & IFF_UP) == 0 ||
sc->gre_family == 0 ||
- (error = gre_check_nesting(ifp, m)) != 0) {
+ (error = if_tunnel_check_nesting(ifp, m, MTAG_GRE,
+ V_max_gre_nesting)) != 0) {
m_freem(m);
goto drop;
}