cgi-bin/bgplg 'show ip bgp as' fails with as < 10

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

cgi-bin/bgplg 'show ip bgp as' fails with as < 10

Pierre Emeriaud
Hello,


I found an interesting behavior with bgplg when used as cgi-bin. It
fails with "show ip bgp {as|source-as|transit-as}" at least when as is
< 10.

No issues whatsoever with bgplgsh:

lg.synhacx.eu.org> show ip bgp as 3
flags: * = Valid, > = Selected, I = via IBGP, A = Announced, S = Stale
origin: i = IGP, e = EGP, ? = Incomplete
flags destination          gateway          lpref   med aspath origin
*>    2603:4000::/32       2001:470:12:1b6::1    100     0 6939 3 i
*     2603:4000::/32       2a06:e880:100f:fffe:25::1    100     0
200753 6939 3 i
<snip>

but this same request
https://lg.synhacx.eu.org/cgi-bin/bgplg?cmd=show+ip+bgp+as&req=3 in
the cgi just outputs "failed."

If you want to check with a router that only have legacy IP, AS1 and 2
originate only a few routes.

Thanks,
pierre

Reply | Threaded
Open this post in threaded view
|

Re: cgi-bin/bgplg 'show ip bgp as' fails with as < 10

Pierre Emeriaud
2018-03-01 11:36 GMT+01:00 Pierre Emeriaud <[hidden email]>:

> Hello,
>
>
> I found an interesting behavior with bgplg when used as cgi-bin. It
> fails with "show ip bgp {as|source-as|transit-as}" at least when as is
> < 10.
>
> No issues whatsoever with bgplgsh:
>
> lg.synhacx.eu.org> show ip bgp as 3
> flags: * = Valid, > = Selected, I = via IBGP, A = Announced, S = Stale
> origin: i = IGP, e = EGP, ? = Incomplete
> flags destination          gateway          lpref   med aspath origin
> *>    2603:4000::/32       2001:470:12:1b6::1    100     0 6939 3 i
> *     2603:4000::/32       2a06:e880:100f:fffe:25::1    100     0
> 200753 6939 3 i
> <snip>
>
> but this same request
> https://lg.synhacx.eu.org/cgi-bin/bgplg?cmd=show+ip+bgp+as&req=3 in
> the cgi just outputs "failed."
>
> If you want to check with a router that only have legacy IP, AS1 and 2
> originate only a few routes.
>
> Thanks,
> pierre

Reply | Threaded
Open this post in threaded view
|

Re: cgi-bin/bgplg 'show ip bgp as' fails with as < 10

Pierre Emeriaud
In reply to this post by Pierre Emeriaud
> I found an interesting behavior with bgplg when used as cgi-bin. It
> fails with "show ip bgp {as|source-as|transit-as}" at least when as is
> < 10.

Fwiw, I works when using two digits:
https://lg.synhacx.eu.org/cgi-bin/bgplg?cmd=show+ip+bgp+as&req=03

Reply | Threaded
Open this post in threaded view
|

Re: cgi-bin/bgplg 'show ip bgp as' fails with as < 10

Pierre Emeriaud
2018-03-01 16:50 GMT+01:00 Pierre Emeriaud <[hidden email]>:
>> I found an interesting behavior with bgplg when used as cgi-bin. It
>> fails with "show ip bgp {as|source-as|transit-as}" at least when as is
>> < 10.

The following seems to fix the issue, but I may have overlooked some
things. Both cgi-bin and bgplgsh works fine now. Thanks Denis :)

Index: bgplg.c
===================================================================
RCS file: /cvs/src/usr.bin/bgplg/bgplg.c,v
retrieving revision 1.18
diff -u -p -r1.18 bgplg.c
--- bgplg.c     18 Dec 2017 09:12:49 -0000      1.18
+++ bgplg.c     2 Mar 2018 13:29:57 -0000
@@ -160,7 +160,7 @@ lg_arg2argv(char *arg, int *argc)
        len = strlen(arg);

        /* Count elements */
-       for (i = 0; i < (len - 1); i++) {
+       for (i = 0; i < len; i++) {
                if (isspace((unsigned char)arg[i])) {
                        /* filter out additional options */
                        if (arg[i + 1] == '-') {
@@ -182,7 +182,7 @@ lg_arg2argv(char *arg, int *argc)
        *argc = c;

        /* Fill array */
-       for (i = c = 0; i < (len - 1); i++) {
+       for (i = c = 0; i < len; i++) {
                if (arg[i] == '\0' || i == 0) {
                        if (i != 0)
                                ptr = &arg[i + 1];