summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorRenato Westphal <renato@cvs.openbsd.org>2015-07-21 05:44:51 +0000
committerRenato Westphal <renato@cvs.openbsd.org>2015-07-21 05:44:51 +0000
commit0c89e71f3b143ef65f1496b5c095e18273e0f98f (patch)
tree5479f98390aef039d9183bee3bf35eda7667a9c4 /usr.sbin
parenta68184c77a2df3df07d773c112262415fd8eea59 (diff)
Introduce two show commands for l2vpns.
ok claudio@
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/ldpctl/ldpctl.88
-rw-r--r--usr.sbin/ldpctl/ldpctl.c97
-rw-r--r--usr.sbin/ldpctl/parser.c13
-rw-r--r--usr.sbin/ldpctl/parser.h4
4 files changed, 115 insertions, 7 deletions
diff --git a/usr.sbin/ldpctl/ldpctl.8 b/usr.sbin/ldpctl/ldpctl.8
index 630697207e6..6bb01b2fb5c 100644
--- a/usr.sbin/ldpctl/ldpctl.8
+++ b/usr.sbin/ldpctl/ldpctl.8
@@ -1,4 +1,4 @@
-.\" $OpenBSD: ldpctl.8,v 1.7 2015/07/21 05:43:46 renato Exp $
+.\" $OpenBSD: ldpctl.8,v 1.8 2015/07/21 05:44:50 renato Exp $
.\"
.\" Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
.\" Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org>
@@ -75,7 +75,11 @@ Show details for all interfaces.
.It Cm show neighbor
Show neighbors.
.It Cm show lib
-Show the Label Information Base.
+Show the IPv4 Label Information Base.
+.It Cm show l2vpn bindings
+Show the PWID Label Information Base.
+.It Cm show l2vpn pseudowires
+Show the status of the configured pseudowires.
.El
.Sh FILES
.Bl -tag -width "/var/run/ldpd.sockXX" -compact
diff --git a/usr.sbin/ldpctl/ldpctl.c b/usr.sbin/ldpctl/ldpctl.c
index 56fc1a38f9a..9f05b7a2fdf 100644
--- a/usr.sbin/ldpctl/ldpctl.c
+++ b/usr.sbin/ldpctl/ldpctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ldpctl.c,v 1.19 2015/07/21 05:42:50 renato Exp $
+/* $OpenBSD: ldpctl.c,v 1.20 2015/07/21 05:44:50 renato Exp $
*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -52,8 +52,11 @@ void show_fib_head(void);
int show_fib_msg(struct imsg *);
void show_interface_head(void);
int show_fib_interface_msg(struct imsg *);
+int show_l2vpn_pw_msg(struct imsg *);
+int show_l2vpn_binding_msg(struct imsg *);
const char *get_media_descr(int);
void print_baudrate(u_int64_t);
+const char *print_pw_type(u_int16_t);
struct imsgbuf *ibuf;
@@ -147,6 +150,15 @@ main(int argc, char *argv[])
imsg_compose(ibuf, IMSG_CTL_IFINFO, 0, 0, -1, NULL, 0);
show_interface_head();
break;
+ case SHOW_L2VPN_PW:
+ printf("%-11s %-15s %-14s %-10s\n",
+ "Interface", "Neighbor", "PWID", "Status");
+ imsg_compose(ibuf, IMSG_CTL_SHOW_L2VPN_PW, 0, 0, -1, NULL, 0);
+ break;
+ case SHOW_L2VPN_BINDING:
+ imsg_compose(ibuf, IMSG_CTL_SHOW_L2VPN_BINDING, 0, 0, -1,
+ NULL, 0);
+ break;
case FIB:
errx(1, "fib couple|decouple");
break;
@@ -211,6 +223,12 @@ main(int argc, char *argv[])
case SHOW_FIB_IFACE:
done = show_fib_interface_msg(&imsg);
break;
+ case SHOW_L2VPN_PW:
+ done = show_l2vpn_pw_msg(&imsg);
+ break;
+ case SHOW_L2VPN_BINDING:
+ done = show_l2vpn_binding_msg(&imsg);
+ break;
case NONE:
case FIB:
case FIB_COUPLE:
@@ -533,6 +551,67 @@ show_fib_interface_msg(struct imsg *imsg)
return (0);
}
+int
+show_l2vpn_pw_msg(struct imsg *imsg)
+{
+ struct ctl_pw *pw;
+
+ switch (imsg->hdr.type) {
+ case IMSG_CTL_SHOW_L2VPN_PW:
+ pw = imsg->data;
+
+ printf("%-11s %-15s %-14u %-10s\n", pw->ifname,
+ inet_ntoa(pw->nexthop), pw->pwid,
+ (pw->status ? "UP" : "DOWN"));
+ break;
+ case IMSG_CTL_END:
+ printf("\n");
+ return (1);
+ default:
+ break;
+ }
+
+ return (0);
+}
+
+int
+show_l2vpn_binding_msg(struct imsg *imsg)
+{
+ struct ctl_pw *pw;
+
+ switch (imsg->hdr.type) {
+ case IMSG_CTL_SHOW_L2VPN_BINDING:
+ pw = imsg->data;
+
+ printf("Neighbor: %s - PWID: %u (%s)\n",
+ inet_ntoa(pw->nexthop), pw->pwid,
+ print_pw_type(pw->type));
+ printf("%-12s%-15s%-15s%-10s\n", "", "Label", "Group-ID",
+ "MTU");
+ if (pw->local_label != NO_LABEL)
+ printf(" %-10s%-15u%-15u%u\n", "Local",
+ pw->local_label, pw->local_gid, pw->local_ifmtu);
+ else
+ printf(" %-10s%-15s%-15s%s\n", "Local", "-",
+ "-", "-");
+ if (pw->remote_label != NO_LABEL)
+ printf(" %-10s%-15u%-15u%u\n", "Remote",
+ pw->remote_label, pw->remote_gid,
+ pw->remote_ifmtu);
+ else
+ printf(" %-10s%-15s%-15s%s\n", "Remote", "-",
+ "-", "-");
+ break;
+ case IMSG_CTL_END:
+ printf("\n");
+ return (1);
+ default:
+ break;
+ }
+
+ return (0);
+}
+
const struct if_status_description
if_status_descriptions[] = LINK_STATE_DESCRIPTIONS;
const struct ifmedia_description
@@ -576,3 +655,19 @@ print_baudrate(u_int64_t baudrate)
else
printf("%llu Bit/s", baudrate);
}
+
+const char *
+print_pw_type(u_int16_t pw_type)
+{
+ static char buf[64];
+
+ switch (pw_type) {
+ case PW_TYPE_ETHERNET_TAGGED:
+ return ("Eth Tagged");
+ case PW_TYPE_ETHERNET:
+ return ("Ethernet");
+ default:
+ snprintf(buf, sizeof(buf), "[%0x]", pw_type);
+ return (buf);
+ }
+}
diff --git a/usr.sbin/ldpctl/parser.c b/usr.sbin/ldpctl/parser.c
index 660e023ed7f..96d93d7ba9b 100644
--- a/usr.sbin/ldpctl/parser.c
+++ b/usr.sbin/ldpctl/parser.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: parser.c,v 1.7 2015/07/21 05:43:46 renato Exp $ */
+/* $OpenBSD: parser.c,v 1.8 2015/07/21 05:44:50 renato Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
@@ -55,11 +55,11 @@ static const struct token t_fib[];
static const struct token t_show[];
static const struct token t_show_iface[];
static const struct token t_show_disc[];
-static const struct token t_show_db[];
-static const struct token t_show_area[];
+
static const struct token t_show_nbr[];
static const struct token t_show_lib[];
static const struct token t_show_fib[];
+static const struct token t_show_l2vpn[];
static const struct token t_log[];
static const struct token t_main[] = {
@@ -83,6 +83,7 @@ static const struct token t_show[] = {
{KEYWORD, "neighbor", SHOW_NBR, t_show_nbr},
{KEYWORD, "lib", SHOW_LIB, t_show_lib},
{KEYWORD, "fib", SHOW_FIB, t_show_fib},
+ {KEYWORD, "l2vpn", NONE, t_show_l2vpn},
{ENDTOKEN, "", NONE, NULL}
};
@@ -121,6 +122,12 @@ static const struct token t_show_fib[] = {
{ENDTOKEN, "", NONE, NULL}
};
+static const struct token t_show_l2vpn[] = {
+ {KEYWORD, "bindings", SHOW_L2VPN_BINDING, NULL},
+ {KEYWORD, "pseudowires", SHOW_L2VPN_PW, NULL},
+ {ENDTOKEN, "", NONE, NULL}
+};
+
static const struct token *match_token(const char *, const struct token *,
struct parse_result *);
static void show_valid_args(const struct token *);
diff --git a/usr.sbin/ldpctl/parser.h b/usr.sbin/ldpctl/parser.h
index 0a824783236..843391881ab 100644
--- a/usr.sbin/ldpctl/parser.h
+++ b/usr.sbin/ldpctl/parser.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: parser.h,v 1.6 2013/06/04 02:40:17 claudio Exp $ */
+/* $OpenBSD: parser.h,v 1.7 2015/07/21 05:44:50 renato Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
@@ -39,6 +39,8 @@ enum actions {
SHOW_LIB,
SHOW_FIB,
SHOW_FIB_IFACE,
+ SHOW_L2VPN_PW,
+ SHOW_L2VPN_BINDING,
RELOAD
};