Add routing boilerplate to eco_output, verbatim from ether_output.

Update copyright notice to include UCB in consequence.
This commit is contained in:
bjh21 2001-09-13 18:01:34 +00:00
parent 28b7bb87a2
commit 3f063023fa

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_ecosubr.c,v 1.1 2001/09/10 23:11:06 bjh21 Exp $ */
/* $NetBSD: if_ecosubr.c,v 1.2 2001/09/13 18:01:34 bjh21 Exp $ */
/*-
* Copyright (c) 2001 Ben Harris
@ -26,14 +26,49 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* Copyright (c) 1982, 1989, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)if_ethersubr.c 8.2 (Berkeley) 4/4/96
*/
#include "bpfilter.h"
#include <sys/param.h>
__KERNEL_RCSID(0, "$NetBSD: if_ecosubr.c,v 1.1 2001/09/10 23:11:06 bjh21 Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_ecosubr.c,v 1.2 2001/09/13 18:01:34 bjh21 Exp $");
#include <sys/errno.h>
#include <sys/kernel.h>
#include <sys/socket.h>
#include <sys/sockio.h>
#include <sys/syslog.h>
@ -43,6 +78,7 @@ __KERNEL_RCSID(0, "$NetBSD: if_ecosubr.c,v 1.1 2001/09/10 23:11:06 bjh21 Exp $")
#include <net/if_dl.h>
#include <net/if_eco.h>
#include <net/if_types.h>
#include <net/route.h>
#if NBPFILTER > 0
#include <net/bpf.h>
@ -101,12 +137,45 @@ eco_output(struct ifnet *ifp, struct mbuf *m0, struct sockaddr *dst,
struct eco_header ehdr, *eh;
int error, s;
struct mbuf *m = m0;
struct rtentry *rt;
int hdrcmplt;
size_t len;
ALTQ_DECL(struct altq_pktattr pktattr;)
if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING))
senderr(ENETDOWN);
if ((rt = rt0) != NULL) {
if ((rt->rt_flags & RTF_UP) == 0) {
if ((rt0 = rt = rtalloc1(dst, 1)) != NULL) {
rt->rt_refcnt--;
if (rt->rt_ifp != ifp)
return (*rt->rt_ifp->if_output)
(ifp, m0, dst, rt);
} else
senderr(EHOSTUNREACH);
}
if ((rt->rt_flags & RTF_GATEWAY) && dst->sa_family != AF_NS) {
if (rt->rt_gwroute == 0)
goto lookup;
if (((rt = rt->rt_gwroute)->rt_flags & RTF_UP) == 0) {
rtfree(rt); rt = rt0;
lookup: rt->rt_gwroute = rtalloc1(rt->rt_gateway, 1);
if ((rt = rt->rt_gwroute) == 0)
senderr(EHOSTUNREACH);
/* the "G" test below also prevents rt == rt0 */
if ((rt->rt_flags & RTF_GATEWAY) ||
(rt->rt_ifp != ifp)) {
rt->rt_refcnt--;
rt0->rt_gwroute = 0;
senderr(EHOSTUNREACH);
}
}
}
if (rt->rt_flags & RTF_REJECT)
if (rt->rt_rmx.rmx_expire == 0 ||
time.tv_sec < rt->rt_rmx.rmx_expire)
senderr(rt == rt0 ? EHOSTDOWN : EHOSTUNREACH);
}
/*
* If the queueing discipline needs packet classification,
* do it before prepending link headers.