diff options
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/ldpctl/ldpctl.c | 28 | ||||
-rw-r--r-- | usr.sbin/ldpd/kroute.c | 16 | ||||
-rw-r--r-- | usr.sbin/ldpd/lde.c | 7 | ||||
-rw-r--r-- | usr.sbin/ldpd/lde_lib.c | 21 |
4 files changed, 30 insertions, 42 deletions
diff --git a/usr.sbin/ldpctl/ldpctl.c b/usr.sbin/ldpctl/ldpctl.c index e88611f5898..3316763ba2a 100644 --- a/usr.sbin/ldpctl/ldpctl.c +++ b/usr.sbin/ldpctl/ldpctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ldpctl.c,v 1.9 2010/04/13 15:42:09 michele Exp $ +/* $OpenBSD: ldpctl.c,v 1.10 2010/06/07 13:24:23 claudio Exp $ * * Copyright (c) 2009 Michele Marchetto <michele@openbsd.org> * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org> @@ -320,7 +320,6 @@ show_lib_msg(struct imsg *imsg) { struct ctl_rt *rt; char *dstnet, *remote; - int remote_label; switch (imsg->hdr.type) { case IMSG_CTL_SHOW_LIB: @@ -328,26 +327,23 @@ show_lib_msg(struct imsg *imsg) if (asprintf(&dstnet, "%s/%d", inet_ntoa(rt->prefix), rt->prefixlen) == -1) err(1, NULL); - remote_label = ntohl(rt->remote_label) >> MPLS_LABEL_OFFSET; if (!rt->in_use) { if (asprintf(&remote, "-") == -1) err(1, NULL); - } else if (rt->connected || - (remote_label == (NO_LABEL >> MPLS_LABEL_OFFSET))) { + } else if (rt->connected || rt->remote_label == NO_LABEL) { if (asprintf(&remote, "Untagged") == -1) err(1, NULL); - } else if (remote_label == MPLS_LABEL_IMPLNULL) { + } else if (rt->remote_label == MPLS_LABEL_IMPLNULL) { if (asprintf(&remote, "Pop tag") == -1) err(1, NULL); } else { - if (asprintf(&remote, "%u", remote_label) == -1) + if (asprintf(&remote, "%u", rt->remote_label) == -1) err(1, NULL); } printf("%-20s %-17s %-14u %-14s %s\n", dstnet, - inet_ntoa(rt->nexthop), - (ntohl(rt->local_label) >> MPLS_LABEL_OFFSET), - remote, rt->in_use ? "yes" : "no"); + inet_ntoa(rt->nexthop), rt->local_label, remote, + rt->in_use ? "yes" : "no"); free(remote); free(dstnet); @@ -439,21 +435,17 @@ show_lfib_msg(struct imsg *imsg) if (k->local_label == NO_LABEL) { printf("%-18s", "-"); - } else if (ntohl(k->local_label) >> MPLS_LABEL_OFFSET == - MPLS_LABEL_IMPLNULL) { + } else if (k->local_label == MPLS_LABEL_IMPLNULL) { printf("%-18s", "imp-null"); } else - printf("%-18u", (ntohl(k->local_label) >> - MPLS_LABEL_OFFSET)); + printf("%-18u", k->local_label); if (k->remote_label == NO_LABEL) { printf("-"); - } else if (htonl(k->remote_label) >> MPLS_LABEL_OFFSET == - MPLS_LABEL_IMPLNULL) { + } else if (k->remote_label == MPLS_LABEL_IMPLNULL) { printf("Pop"); } else { - printf("%u", (ntohl(k->remote_label) >> - MPLS_LABEL_OFFSET)); + printf("%u", k->remote_label); } printf("\n"); diff --git a/usr.sbin/ldpd/kroute.c b/usr.sbin/ldpd/kroute.c index cfcc3d6b31a..46ad1f17ba2 100644 --- a/usr.sbin/ldpd/kroute.c +++ b/usr.sbin/ldpd/kroute.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kroute.c,v 1.12 2010/05/25 13:29:45 claudio Exp $ */ +/* $OpenBSD: kroute.c,v 1.13 2010/06/07 13:24:23 claudio Exp $ */ /* * Copyright (c) 2009 Michele Marchetto <michele@openbsd.org> @@ -1026,7 +1026,7 @@ send_rtmsg(int fd, int action, struct kroute *kroute, u_int32_t family) return (0); /* Implicit NULL label should be added/remove just one time */ - hr_label = ntohl(kroute->local_label) >> MPLS_LABEL_OFFSET; + hr_label = kroute->local_label; if (hr_label == MPLS_LABEL_IMPLNULL) { if (action == RTM_ADD && flag_implicit_null) return (0); @@ -1053,7 +1053,8 @@ send_rtmsg(int fd, int action, struct kroute *kroute, u_int32_t family) bzero(&label_in, sizeof(label_in)); label_in.smpls_len = sizeof(label_in); label_in.smpls_family = AF_MPLS; - label_in.smpls_label = kroute->local_label; + label_in.smpls_label = + htonl(kroute->local_label << MPLS_LABEL_OFFSET); /* adjust header */ hdr.rtm_flags |= RTF_MPLS; hdr.rtm_priority = RTP_DEFAULT; @@ -1106,7 +1107,8 @@ send_rtmsg(int fd, int action, struct kroute *kroute, u_int32_t family) bzero(&label_out, sizeof(label_out)); label_out.smpls_len = sizeof(label_out); label_out.smpls_family = AF_MPLS; - label_out.smpls_label = kroute->remote_label; + label_out.smpls_label = + htonl(kroute->remote_label << MPLS_LABEL_OFFSET); /* adjust header */ hdr.rtm_addrs |= RTA_SRC; hdr.rtm_flags |= RTF_MPLS; @@ -1115,8 +1117,7 @@ send_rtmsg(int fd, int action, struct kroute *kroute, u_int32_t family) iov[iovcnt].iov_base = &label_out; iov[iovcnt++].iov_len = sizeof(label_out); - if (ntohl(kroute->remote_label) >> MPLS_LABEL_OFFSET == - MPLS_LABEL_IMPLNULL) { + if (kroute->remote_label == MPLS_LABEL_IMPLNULL) { if (family == AF_MPLS) hdr.rtm_mpls = MPLS_OP_POP; else @@ -1268,7 +1269,8 @@ fetchtable(void) if ((sa_mpls = (struct sockaddr_mpls *)rti_info[RTAX_SRC]) != NULL) - kr->r.local_label = sa_mpls->smpls_label; + kr->r.local_label = + ntohl(sa_mpls->smpls_label) >> MPLS_LABEL_OFFSET; kroute_insert(kr); diff --git a/usr.sbin/ldpd/lde.c b/usr.sbin/ldpd/lde.c index a4780e87ce1..cfcaa376254 100644 --- a/usr.sbin/ldpd/lde.c +++ b/usr.sbin/ldpd/lde.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lde.c,v 1.15 2010/06/02 11:56:29 claudio Exp $ */ +/* $OpenBSD: lde.c,v 1.16 2010/06/07 13:24:23 claudio Exp $ */ /* * Copyright (c) 2004, 2005 Claudio Jeker <claudio@openbsd.org> @@ -426,7 +426,7 @@ lde_assign_label(void) /* XXX some checks needed */ label++; - return (htonl(label << MPLS_LABEL_OFFSET)); + return label; } void @@ -605,8 +605,7 @@ lde_nbr_do_mappings(struct rt_node *rn) struct lde_req *lr; struct map map; - map.label = (ntohl(rn->local_label) & MPLS_LABEL_MASK) >> - MPLS_LABEL_OFFSET; + map.label = rn->local_label; map.prefix = rn->fec.prefix.s_addr; map.prefixlen = rn->fec.prefixlen; diff --git a/usr.sbin/ldpd/lde_lib.c b/usr.sbin/ldpd/lde_lib.c index 032ab63694b..ff35119e15d 100644 --- a/usr.sbin/ldpd/lde_lib.c +++ b/usr.sbin/ldpd/lde_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lde_lib.c,v 1.19 2010/06/02 11:56:29 claudio Exp $ */ +/* $OpenBSD: lde_lib.c,v 1.20 2010/06/07 13:24:23 claudio Exp $ */ /* * Copyright (c) 2009 Michele Marchetto <michele@openbsd.org> @@ -161,8 +161,7 @@ rt_snap(u_int32_t peerid) r = (struct rt_node *)f; map.prefix = r->fec.prefix.s_addr; map.prefixlen = r->fec.prefixlen; - map.label = (ntohl(r->local_label) & MPLS_LABEL_MASK) >> - MPLS_LABEL_OFFSET; + map.label = r->local_label; lde_imsg_compose_ldpe(IMSG_MAPPING_ADD, peerid, 0, &map, sizeof(map)); @@ -219,8 +218,7 @@ lde_kernel_insert(struct kroute *kr) LIST_FOREACH(map, &rn->downstream, entry) { addr = lde_address_find(map->nexthop, &rn->nexthop); if (addr != NULL) { - rn->remote_label = - htonl(map->label << MPLS_LABEL_OFFSET); + rn->remote_label = map->label; break; } } @@ -238,15 +236,14 @@ lde_kernel_insert(struct kroute *kr) /* There is static assigned label for this route, record it in lib */ if (kr->local_label != NO_LABEL) { - rn->local_label = htonl(kr->local_label << MPLS_LABEL_OFFSET); + rn->local_label = kr->local_label; return; } LIST_FOREACH(map, &rn->downstream, entry) { addr = lde_address_find(map->nexthop, &rn->nexthop); if (addr != NULL) { - rn->remote_label = - htonl(map->label << MPLS_LABEL_OFFSET); + rn->remote_label = map->label; break; } } @@ -254,8 +251,7 @@ lde_kernel_insert(struct kroute *kr) if (rn->local_label == NO_LABEL) { /* Directly connected route */ if (kr->nexthop.s_addr == INADDR_ANY) { - rn->local_label = - htonl(MPLS_LABEL_IMPLNULL << MPLS_LABEL_OFFSET); + rn->local_label = MPLS_LABEL_IMPLNULL; rn->nexthop.s_addr = htonl(INADDR_LOOPBACK); } else rn->local_label = lde_assign_label(); @@ -286,8 +282,7 @@ lde_kernel_remove(struct kroute *kr) if (map == NULL) fatal("lde_kernel_remove"); - map->label = (ntohl(rn->remote_label) & - MPLS_LABEL_MASK) >> MPLS_LABEL_OFFSET; + map->label = rn->remote_label; map->fec = rn->fec; map->nexthop = ln; LIST_INSERT_HEAD(&rn->downstream, map, entry); @@ -377,7 +372,7 @@ lde_check_mapping(struct map *map, struct lde_nbr *ln) return; } - rn->remote_label = htonl(map->label << MPLS_LABEL_OFFSET); + rn->remote_label = map->label; /* If we are ingress for this LSP install the label */ if (rn->nexthop.s_addr == INADDR_ANY) |