From d8b371b3b2e4f4e3d8ec306e1aab0e76f0668d5c Mon Sep 17 00:00:00 2001 From: mpi Date: Thu, 8 May 2014 09:28:08 +0000 Subject: [PATCH] Introduce two new route flags: RTF_LOCAL and RTF_BROADCAST. Nothing use them for the moment, but here is the plan: Since a route lookup is always necessary to output a packet it makes sense to store all the information regarding how the packet should be sent in the routing entry. This will save us some expensive lookups on address lists. But once we have all the information about our addresses in the routing table, we can even use it in the input path with the hope that the number of lookups in the forwarding case can be reduce to one. ok henning@, chris@ --- sbin/route/route.c | 6 ++++-- sbin/route/show.c | 4 +++- sys/net/route.h | 13 +++++-------- usr.bin/netstat/netstat.1 | 6 ++++-- usr.bin/netstat/show.c | 4 +++- 5 files changed, 19 insertions(+), 14 deletions(-) diff --git a/sbin/route/route.c b/sbin/route/route.c index 5cf0a35cca6..387cca18495 100644 --- a/sbin/route/route.c +++ b/sbin/route/route.c @@ -1,4 +1,4 @@ -/* $OpenBSD: route.c,v 1.166 2014/01/22 06:23:37 claudio Exp $ */ +/* $OpenBSD: route.c,v 1.167 2014/05/08 09:28:08 mpi Exp $ */ /* $NetBSD: route.c,v 1.16 1996/04/15 18:27:05 cgd Exp $ */ /* @@ -1243,7 +1243,7 @@ char metricnames[] = "\011priority\010rttvar\7rtt\6ssthresh\5sendpipe\4recvpipe\3expire\2hopcount\1mtu"; char routeflags[] = "\1UP\2GATEWAY\3HOST\4REJECT\5DYNAMIC\6MODIFIED\7DONE\010MASK_PRESENT\011CLONING" -"\012XRESOLVE\013LLINFO\014STATIC\015BLACKHOLE\016PROTO3\017PROTO2\020PROTO1\021CLONED\022SOURCE\023MPATH\025MPLS"; +"\012XRESOLVE\013LLINFO\014STATIC\015BLACKHOLE\016PROTO3\017PROTO2\020PROTO1\021CLONED\023MPATH\025MPLS\026LOCAL\027BROADCAST"; char ifnetflags[] = "\1UP\2BROADCAST\3DEBUG\4LOOPBACK\5PTP\6NOTRAILERS\7RUNNING\010NOARP\011PPROMISC" "\012ALLMULTI\013OACTIVE\014SIMPLEX\015LINK0\016LINK1\017LINK2\020MULTICAST"; @@ -1352,6 +1352,8 @@ priorityname(u_int8_t prio) switch (prio) { case RTP_NONE: return ("none"); + case RTP_LOCAL: + return ("local"); case RTP_CONNECTED: return ("connected"); case RTP_STATIC: diff --git a/sbin/route/show.c b/sbin/route/show.c index 59fe7eae26a..0f9c2e5ba8e 100644 --- a/sbin/route/show.c +++ b/sbin/route/show.c @@ -1,4 +1,4 @@ -/* $OpenBSD: show.c,v 1.95 2014/04/17 15:35:35 claudio Exp $ */ +/* $OpenBSD: show.c,v 1.96 2014/05/08 09:28:08 mpi Exp $ */ /* $NetBSD: show.c,v 1.1 1996/11/15 18:01:41 gwr Exp $ */ /* @@ -93,6 +93,8 @@ static const struct bits bits[] = { { RTF_CLONED, 'c' }, { RTF_MPATH, 'P' }, { RTF_MPLS, 'T' }, + { RTF_LOCAL, 'l' }, + { RTF_BROADCAST, 'b' }, { 0 } }; diff --git a/sys/net/route.h b/sys/net/route.h index 988b8742c9d..6be2320d8f3 100644 --- a/sys/net/route.h +++ b/sys/net/route.h @@ -1,4 +1,4 @@ -/* $OpenBSD: route.h,v 1.92 2014/04/25 10:41:09 mpi Exp $ */ +/* $OpenBSD: route.h,v 1.93 2014/05/08 09:28:08 mpi Exp $ */ /* $NetBSD: route.h,v 1.9 1996/02/13 22:00:49 christos Exp $ */ /* @@ -127,7 +127,7 @@ struct rtentry { #define RTF_MASK 0x80 /* subnet mask present */ #define RTF_CLONING 0x100 /* generate new routes on use */ #define RTF_XRESOLVE 0x200 /* external daemon resolves name */ -#define RTF_LLINFO 0x400 /* generated by ARP or ESIS */ +#define RTF_LLINFO 0x400 /* generated by ARP or ND */ #define RTF_STATIC 0x800 /* manually added */ #define RTF_BLACKHOLE 0x1000 /* just discard pkts (during updates) */ #define RTF_PROTO3 0x2000 /* protocol specific routing flag */ @@ -136,20 +136,17 @@ struct rtentry { #define RTF_CLONED 0x10000 /* this is a cloned route */ #define RTF_MPATH 0x40000 /* multipath route or operation */ #define RTF_MPLS 0x100000 /* MPLS additional infos */ +#define RTF_LOCAL 0x200000 /* route to a local address */ +#define RTF_BROADCAST 0x400000 /* route associated to a bcast addr. */ /* mask of RTF flags that are allowed to be modified by RTM_CHANGE */ #define RTF_FMASK \ (RTF_PROTO1 | RTF_PROTO2 | RTF_PROTO3 | RTF_BLACKHOLE | \ RTF_REJECT | RTF_STATIC | RTF_MPLS) -#ifndef _KERNEL -/* obsoleted */ -#define RTF_SOURCE 0x20000 /* this route has a source selector */ -#define RTF_TUNNEL 0x100000 /* Tunnelling bit. */ -#endif - /* Routing priorities used by the different routing protocols */ #define RTP_NONE 0 /* unset priority use sane default */ +#define RTP_LOCAL 2 /* route to a local address */ #define RTP_CONNECTED 4 /* directly connected routes */ #define RTP_STATIC 8 /* static routes base priority */ #define RTP_OSPF 32 /* OSPF routes */ diff --git a/usr.bin/netstat/netstat.1 b/usr.bin/netstat/netstat.1 index 77438e7be7b..b61c55ca7dc 100644 --- a/usr.bin/netstat/netstat.1 +++ b/usr.bin/netstat/netstat.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: netstat.1,v 1.69 2012/08/22 06:45:44 jmc Exp $ +.\" $OpenBSD: netstat.1,v 1.70 2014/05/08 09:28:08 mpi Exp $ .\" $NetBSD: netstat.1,v 1.11 1995/10/03 21:42:43 thorpej Exp $ .\" .\" Copyright (c) 1983, 1990, 1992, 1993 @@ -30,7 +30,7 @@ .\" .\" from: @(#)netstat.1 8.8 (Berkeley) 4/18/94 .\" -.Dd $Mdocdate: August 22 2012 $ +.Dd $Mdocdate: May 8 2014 $ .Dt NETSTAT 1 .Os .Sh NAME @@ -361,12 +361,14 @@ The mapping between letters and flags is: .It 2 Ta RTF_PROTO2 Ta "Protocol specific routing flag #2." .It 3 Ta RTF_PROTO3 Ta "Protocol specific routing flag #3." .It B Ta RTF_BLACKHOLE Ta "Just discard pkts (during updates)." +.It b Ta RTF_BROADCAST Ta "Correspond to a local broadcast address." .It C Ta RTF_CLONING Ta "Generate new routes on use." .It c Ta RTF_CLONED Ta "Cloned routes (generated from RTF_CLONING)." .It D Ta RTF_DYNAMIC Ta "Created dynamically (by redirect)." .It G Ta RTF_GATEWAY Ta "Destination requires forwarding by intermediary." .It H Ta RTF_HOST Ta "Host entry (net otherwise)." .It L Ta RTF_LLINFO Ta "Valid protocol to link address translation." +.It l Ta RTF_LOCAL Ta "Correspond to a local address." .It M Ta RTF_MODIFIED Ta "Modified dynamically (by redirect)." .It P Ta RTF_MPATH Ta "Multipath route." .It R Ta RTF_REJECT Ta "Host or net unreachable." diff --git a/usr.bin/netstat/show.c b/usr.bin/netstat/show.c index e26074612c7..53ecac7ae9e 100644 --- a/usr.bin/netstat/show.c +++ b/usr.bin/netstat/show.c @@ -1,4 +1,4 @@ -/* $OpenBSD: show.c,v 1.41 2014/04/17 15:36:53 claudio Exp $ */ +/* $OpenBSD: show.c,v 1.42 2014/05/08 09:28:08 mpi Exp $ */ /* $NetBSD: show.c,v 1.1 1996/11/15 18:01:41 gwr Exp $ */ /* @@ -93,6 +93,8 @@ static const struct bits bits[] = { { RTF_CLONED, 'c' }, { RTF_MPATH, 'P' }, { RTF_MPLS, 'T' }, + { RTF_LOCAL, 'l' }, + { RTF_BROADCAST, 'b' }, { 0 } }; -- 2.20.1