summaryrefslogtreecommitdiffstats
path: root/sys/net/if_ethersubr.c
diff options
context:
space:
mode:
authormdodd <mdodd@FreeBSD.org>2003-03-02 21:34:37 +0000
committermdodd <mdodd@FreeBSD.org>2003-03-02 21:34:37 +0000
commitcd4fafb346eda353b75a3fb1f4ba5b08a8f0e688 (patch)
tree029d8e13f59ab838fe4627ca66354af3d3e0b962 /sys/net/if_ethersubr.c
parent0a50041362fa551b46336f0c3c6d0faf524bc2d7 (diff)
downloadFreeBSD-src-cd4fafb346eda353b75a3fb1f4ba5b08a8f0e688.zip
FreeBSD-src-cd4fafb346eda353b75a3fb1f4ba5b08a8f0e688.tar.gz
Reduce code duplication. This adds the function rt_check() to route.c.
Approved by: sam (in principle)
Diffstat (limited to 'sys/net/if_ethersubr.c')
-rw-r--r--sys/net/if_ethersubr.c30
1 files changed, 5 insertions, 25 deletions
diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c
index 0af1114..36a614c 100644
--- a/sys/net/if_ethersubr.c
+++ b/sys/net/if_ethersubr.c
@@ -163,31 +163,11 @@ ether_output(ifp, m, dst, rt0)
senderr(ENETDOWN);
if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING))
senderr(ENETDOWN);
- rt = rt0;
- if (rt) {
- if ((rt->rt_flags & RTF_UP) == 0) {
- rt0 = rt = rtalloc1(dst, 1, 0UL);
- if (rt0)
- rt->rt_refcnt--;
- else
- senderr(EHOSTUNREACH);
- }
- if (rt->rt_flags & RTF_GATEWAY) {
- 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,
- 0UL);
- if ((rt = rt->rt_gwroute) == 0)
- senderr(EHOSTUNREACH);
- }
- }
- if (rt->rt_flags & RTF_REJECT)
- if (rt->rt_rmx.rmx_expire == 0 ||
- time_second < rt->rt_rmx.rmx_expire)
- senderr(rt == rt0 ? EHOSTDOWN : EHOSTUNREACH);
- }
+
+ error = rt_check(&rt, &rt0, dst);
+ if (error)
+ goto bad;
+
hlen = ETHER_HDR_LEN;
switch (dst->sa_family) {
#ifdef INET
OpenPOWER on IntegriCloud