Deleted Added
full compact
ip_gre.c (125226) ip_gre.c (127307)
1/* $NetBSD: ip_gre.c,v 1.29 2003/09/05 23:02:43 itojun Exp $ */
1/* $NetBSD: ip_gre.c,v 1.29 2003/09/05 23:02:43 itojun Exp $ */
2/* $FreeBSD: head/sys/netinet/ip_gre.c 125226 2004-01-30 09:03:01Z sobomax $ */
2/* $FreeBSD: head/sys/netinet/ip_gre.c 127307 2004-03-22 16:04:43Z rwatson $ */
3
4/*
5 * Copyright (c) 1998 The NetBSD Foundation, Inc.
6 * All rights reserved.
7 *
8 * This code is derived from software contributed to The NetBSD Foundation
9 * by Heiko W.Rupp <hwr@pilhuhn.de>
10 *

--- 298 unchanged lines hidden (view full) ---

309
310 m->m_pkthdr.rcvif = &sc->sc_if;
311
312 netisr_dispatch(NETISR_IP, m);
313}
314
315/*
316 * Find the gre interface associated with our src/dst/proto set.
3
4/*
5 * Copyright (c) 1998 The NetBSD Foundation, Inc.
6 * All rights reserved.
7 *
8 * This code is derived from software contributed to The NetBSD Foundation
9 * by Heiko W.Rupp <hwr@pilhuhn.de>
10 *

--- 298 unchanged lines hidden (view full) ---

309
310 m->m_pkthdr.rcvif = &sc->sc_if;
311
312 netisr_dispatch(NETISR_IP, m);
313}
314
315/*
316 * Find the gre interface associated with our src/dst/proto set.
317 *
318 * XXXRW: Need some sort of drain/refcount mechanism so that the softc
319 * reference remains valid after it's returned from gre_lookup(). Right
320 * now, I'm thinking it should be reference-counted with a gre_dropref()
321 * when the caller is done with the softc. This is complicated by how
322 * to handle destroying the gre softc; probably using a gre_drain() in
323 * in_gre.c during destroy.
317 */
318static struct gre_softc *
319gre_lookup(m, proto)
320 struct mbuf *m;
321 u_int8_t proto;
322{
323 struct ip *ip = mtod(m, struct ip *);
324 struct gre_softc *sc;
325
324 */
325static struct gre_softc *
326gre_lookup(m, proto)
327 struct mbuf *m;
328 u_int8_t proto;
329{
330 struct ip *ip = mtod(m, struct ip *);
331 struct gre_softc *sc;
332
333 mtx_lock(&gre_mtx);
326 for (sc = LIST_FIRST(&gre_softc_list); sc != NULL;
327 sc = LIST_NEXT(sc, sc_list)) {
328 if ((sc->g_dst.s_addr == ip->ip_src.s_addr) &&
329 (sc->g_src.s_addr == ip->ip_dst.s_addr) &&
330 (sc->g_proto == proto) &&
334 for (sc = LIST_FIRST(&gre_softc_list); sc != NULL;
335 sc = LIST_NEXT(sc, sc_list)) {
336 if ((sc->g_dst.s_addr == ip->ip_src.s_addr) &&
337 (sc->g_src.s_addr == ip->ip_dst.s_addr) &&
338 (sc->g_proto == proto) &&
331 ((sc->sc_if.if_flags & IFF_UP) != 0))
339 ((sc->sc_if.if_flags & IFF_UP) != 0)) {
340 mtx_unlock(&gre_mtx);
332 return (sc);
341 return (sc);
342 }
333 }
343 }
344 mtx_unlock(&gre_mtx);
334
335 return (NULL);
336}
345
346 return (NULL);
347}