summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichele Marchetto <michele@cvs.openbsd.org>2008-12-15 16:14:58 +0000
committerMichele Marchetto <michele@cvs.openbsd.org>2008-12-15 16:14:58 +0000
commit3c02b44c08bc8aa51e2b0669e29ca7085fb86f59 (patch)
tree6bd23c9672e8ff80434d4318942813eea5c93ce3
parent803549b94cd18b0b300c2a3c53d249a16bb5f11d (diff)
Reflect kernel changes. Labels are no more per link unique
and operations are now stored in rt_flags. This also simplify a lot the syntax. ok claudio@ laurent@
-rw-r--r--sbin/route/route.c23
-rw-r--r--sbin/route/show.c29
2 files changed, 25 insertions, 27 deletions
diff --git a/sbin/route/route.c b/sbin/route/route.c
index e3d9e71acc5..c6ec0ff09d2 100644
--- a/sbin/route/route.c
+++ b/sbin/route/route.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: route.c,v 1.121 2008/12/12 20:26:30 claudio Exp $ */
+/* $OpenBSD: route.c,v 1.122 2008/12/15 16:14:57 michele Exp $ */
/* $NetBSD: route.c,v 1.16 1996/04/15 18:27:05 cgd Exp $ */
/*
@@ -400,17 +400,17 @@ newroute(int argc, char **argv)
case K_POP:
if (af != AF_MPLS)
errx(1, "-pop requires -mpls");
- so_dst.smpls.smpls_operation = MPLS_OP_POP;
+ flags |= MPLS_OP_POP;
break;
case K_PUSH:
if (af != AF_MPLS)
errx(1, "-push requires -mpls");
- so_dst.smpls.smpls_operation = MPLS_OP_PUSH;
+ flags |= MPLS_OP_PUSH;
break;
case K_SWAP:
if (af != AF_MPLS)
errx(1, "-swap requires -mpls");
- so_dst.smpls.smpls_operation = MPLS_OP_SWAP;
+ flags |= MPLS_OP_SWAP;
break;
case K_IFACE:
case K_INTERFACE:
@@ -879,31 +879,20 @@ getmplslabel(char *s, int in)
{
sup su = NULL;
const char *errstr;
- char *ifname;
u_int32_t label;
- u_int16_t ifindex = 0;
rtm_addrs |= RTA_DST;
su = &so_dst;
su->sa.sa_len = aflen;
su->sa.sa_family = af;
- ifname = strchr(s, SCOPE_DELIMITER);
- if (ifname) {
- *ifname++ = '\0';
- ifindex = if_nametoindex(ifname);
- }
-
label = strtonum(s, 0, 0x000fffff, &errstr);
if (errstr)
errx(1, "bad label: %s is %s", s, errstr);
- if (in) {
+ if (in)
su->smpls.smpls_in_label = htonl(label << MPLS_LABEL_OFFSET);
- su->smpls.smpls_in_ifindex = ifindex;
- } else {
+ else
su->smpls.smpls_out_label = htonl(label << MPLS_LABEL_OFFSET);
- su->smpls.smpls_out_ifindex = ifindex;
- }
}
int
diff --git a/sbin/route/show.c b/sbin/route/show.c
index c6c50398951..016ea584956 100644
--- a/sbin/route/show.c
+++ b/sbin/route/show.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: show.c,v 1.72 2008/12/12 20:26:30 claudio Exp $ */
+/* $OpenBSD: show.c,v 1.73 2008/12/15 16:14:57 michele Exp $ */
/* $NetBSD: show.c,v 1.1 1996/11/15 18:01:41 gwr Exp $ */
/*
@@ -59,7 +59,7 @@
char *any_ntoa(const struct sockaddr *);
char *link_print(struct sockaddr *);
-char *label_print_op(u_int8_t);
+char *label_print_op(u_int32_t);
char *label_print(struct sockaddr *);
extern int nflag;
@@ -300,6 +300,7 @@ p_rtentry(struct rt_msghdr *rtm)
p_sockaddr(sa, mask, rtm->rtm_flags, WID_DST(sa->sa_family));
p_sockaddr(rti_info[RTAX_GATEWAY], NULL, RTF_HOST,
WID_GW(sa->sa_family));
+
p_flags(rtm->rtm_flags, "%-6.6s ");
printf("%5u %8llu ", rtm->rtm_rmx.rmx_refcnt,
rtm->rtm_rmx.rmx_pksent);
@@ -514,6 +515,16 @@ p_sockaddr(struct sockaddr *sa, struct sockaddr *mask, int flags, int width)
cp = netname((struct sockaddr *)sa6, mask);
break;
}
+ case AF_MPLS:
+ if (flags & RTF_HOST || mask == NULL)
+ cp = routename(sa);
+ else
+ cp = netname(sa, mask);
+
+ snprintf(cp, MAXHOSTNAMELEN, "%s %s", cp,
+ label_print_op(flags));
+
+ break;
default:
if ((flags & RTF_HOST) || mask == NULL)
cp = routename(sa);
@@ -855,9 +866,9 @@ link_print(struct sockaddr *sa)
}
char *
-label_print_op(u_int8_t type)
+label_print_op(u_int32_t type)
{
- switch (type) {
+ switch (type & (MPLS_OP_PUSH | MPLS_OP_POP | MPLS_OP_SWAP)) {
case MPLS_OP_POP:
return ("POP");
case MPLS_OP_SWAP:
@@ -878,18 +889,16 @@ label_print(struct sockaddr *sa)
char *in_label;
char *out_label;
- if (asprintf(&in_label, "%u%%%s",
- ntohl(smpls->smpls_in_label) >> MPLS_LABEL_OFFSET,
- if_indextoname(smpls->smpls_in_ifindex, ifname_in)) == -1)
+ if (asprintf(&in_label, "%u",
+ ntohl(smpls->smpls_in_label) >> MPLS_LABEL_OFFSET) == -1)
err(1, NULL);
if (asprintf(&out_label, "%u",
ntohl(smpls->smpls_out_label) >> MPLS_LABEL_OFFSET) == -1)
err(1, NULL);
- (void)snprintf(line, sizeof(line), "%-16s %-10s %-6s", in_label,
- smpls->smpls_operation == MPLS_OP_POP ? "-" : out_label,
- label_print_op(smpls->smpls_operation));
+ (void)snprintf(line, sizeof(line), "%-16s %-10s", in_label,
+ out_label);
free(in_label);
free(out_label);