summaryrefslogtreecommitdiff
path: root/sys/net
diff options
context:
space:
mode:
Diffstat (limited to 'sys/net')
-rw-r--r--sys/net/if.c14
-rw-r--r--sys/net/if.h3
-rw-r--r--sys/net/route.c4
-rw-r--r--sys/net/route.h14
4 files changed, 25 insertions, 10 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