diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2008-12-12 22:07:34 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2008-12-12 22:07:34 +0000 |
commit | 31b949d922863f483ab80e2e880d8d6adee8014f (patch) | |
tree | 2483c70a1b2f9ac0bad21129b7058d2f665bbcf5 | |
parent | 5b78a9b707a28bbac3b9990a915717f59df94926 (diff) |
Introduce a if_priority that will be added to RTP_STATIC when routes are
added without an expilict priority. This allows to specify less prefered
interfaces that will only take over if the primary interface loses link.
OK deraadt@
-rw-r--r-- | sys/net/if.c | 14 | ||||
-rw-r--r-- | sys/net/if.h | 3 | ||||
-rw-r--r-- | sys/net/route.c | 4 | ||||
-rw-r--r-- | sys/net/route.h | 14 | ||||
-rw-r--r-- | sys/sys/sockio.h | 5 |
5 files changed, 29 insertions, 11 deletions
diff --git a/sys/net/if.c b/sys/net/if.c index ebe573a28fd..ddb4c5bb1ce 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if.c,v 1.184 2008/12/11 16:45:45 deraadt Exp $ */ +/* $OpenBSD: if.c,v 1.185 2008/12/12 22:07:33 claudio Exp $ */ /* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */ /* @@ -1381,6 +1381,18 @@ ifioctl(struct socket *so, u_long cmd, caddr_t data, struct proc *p) } break; + case SIOCGIFPRIORITY: + ifr->ifr_metric = ifp->if_priority; + break; + + case SIOCSIFPRIORITY: + if ((error = suser(p, 0)) != 0) + return (error); + if (ifr->ifr_metric < 0 || ifr->ifr_metric > 15) + return (EINVAL); + ifp->if_priority = ifr->ifr_metric; + break; + case SIOCAIFGROUP: if ((error = suser(p, 0))) return (error); diff --git a/sys/net/if.h b/sys/net/if.h index 74235314a51..ab6df1ab27f 100644 --- a/sys/net/if.h +++ b/sys/net/if.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if.h,v 1.101 2008/12/11 16:45:45 deraadt Exp $ */ +/* $OpenBSD: if.h,v 1.102 2008/12/12 22:07:33 claudio Exp $ */ /* $NetBSD: if.h,v 1.23 1996/05/07 02:40:27 thorpej Exp $ */ /* @@ -217,6 +217,7 @@ struct ifnet { /* and the entries */ int if_capabilities; /* interface capabilities */ char if_description[IFDESCRSIZE]; /* interface description */ u_short if_rtlabelid; /* next route label */ + u_int8_t if_priority; /* procedure handles */ /* output routine (enqueue) */ diff --git a/sys/net/route.c b/sys/net/route.c index a9feb004fb0..3baafe32598 100644 --- a/sys/net/route.c +++ b/sys/net/route.c @@ -1,4 +1,4 @@ -/* $OpenBSD: route.c,v 1.99 2008/11/24 12:53:53 claudio Exp $ */ +/* $OpenBSD: route.c,v 1.100 2008/12/12 22:07:33 claudio Exp $ */ /* $NetBSD: route.c,v 1.14 1996/02/13 22:00:46 christos Exp $ */ /* @@ -816,6 +816,8 @@ makeroute: senderr(ENOBUFS); Bzero(rt, sizeof(*rt)); rt->rt_flags = info->rti_flags; + if (prio == 0) + prio = ifa->ifa_ifp->if_priority + RTP_STATIC; rt->rt_priority = prio; /* init routing priority */ if ((LINK_STATE_IS_UP(ifa->ifa_ifp->if_link_state) || ifa->ifa_ifp->if_link_state == LINK_STATE_UNKNOWN) && diff --git a/sys/net/route.h b/sys/net/route.h index a42efc2c139..e6385e93100 100644 --- a/sys/net/route.h +++ b/sys/net/route.h @@ -1,4 +1,4 @@ -/* $OpenBSD: route.h,v 1.54 2008/11/24 12:53:53 claudio Exp $ */ +/* $OpenBSD: route.h,v 1.55 2008/12/12 22:07:33 claudio Exp $ */ /* $NetBSD: route.h,v 1.9 1996/02/13 22:00:49 christos Exp $ */ /* @@ -158,12 +158,12 @@ struct rtentry { /* Routing priorities used by the different routing protocols */ #define RTP_NONE 0 /* unset priority use sane default */ #define RTP_CONNECTED 4 /* directly connected routes */ -#define RTP_STATIC 8 /* static routes */ -#define RTP_OSPF 16 /* OSPF routes */ -#define RTP_ISIS 20 /* IS-IS routes */ -#define RTP_RIP 24 /* RIP routes */ -#define RTP_BGP 32 /* BGP routes */ -#define RTP_DEFAULT 48 /* routes that have nothing set */ +#define RTP_STATIC 8 /* static routes base priority */ +#define RTP_OSPF 32 /* OSPF routes */ +#define RTP_ISIS 36 /* IS-IS routes */ +#define RTP_RIP 40 /* RIP routes */ +#define RTP_BGP 48 /* BGP routes */ +#define RTP_DEFAULT 56 /* routes that have nothing set */ #define RTP_MAX 63 /* maximum priority */ #define RTP_ANY 64 /* any of the above */ #define RTP_MASK 0x7f diff --git a/sys/sys/sockio.h b/sys/sys/sockio.h index f3a4a722368..83aaea282e7 100644 --- a/sys/sys/sockio.h +++ b/sys/sys/sockio.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sockio.h,v 1.41 2008/09/09 13:56:39 henning Exp $ */ +/* $OpenBSD: sockio.h,v 1.42 2008/12/12 22:07:33 claudio Exp $ */ /* $NetBSD: sockio.h,v 1.5 1995/08/23 00:40:47 thorpej Exp $ */ /*- @@ -167,6 +167,9 @@ #define SIOCSETLABEL _IOW('i', 153, struct ifreq) /* set MPLS label */ #define SIOCGETLABEL _IOW('i', 154, struct ifreq) /* get MPLS label */ +#define SIOCSIFPRIORITY _IOW('i', 155, struct ifreq) /* set if priority */ +#define SIOCGIFPRIORITY _IOWR('i', 156, struct ifreq) /* get if priority */ + #define SIOCSVH _IOWR('i', 245, struct ifreq) /* set carp param */ #define SIOCGVH _IOWR('i', 246, struct ifreq) /* get carp param */ |