Discussion:
BIRD-1.3.6 - show bgp summary command
Dean Belev
2012-02-23 14:48:00 UTC
Permalink
Hi there,

Is the patch for 1.3.4
(http://marc.info/?l=bird-users&m=132155489919052&w=2
<http://marc.info/?l=bird-users&m=132155489919052&w=2>) usable for 1.3.6 ?

We have a strange behavior when we tried to implement it for 1.3.6 - the
process stops right after the Enter is triggered.
But the "?" function works correctly.

Best~
--
Dean Belev
Network Management Team
Neterra Ltd.
Sofia, Bulgaria
Phone: +359 2 974 33 11
Fax: +359 2 975 34 36
Mobile: +359 886 663 123
http://www.neterra.net
nirn
2012-02-23 14:57:53 UTC
Permalink
Hi
I adapted this the patch to the version 1.3.6,

So far I have no problems and works as shown

BIRD 1.3.6 ready.
bird> show bgp summary
Peer
AS Last state change Prefixes rcvd/best State/Last error
xx.xx.xx.xx
AS123 1329781999 392881/2358 Established
xx.xx.xx.xx
AS123 1329737563 390544/390544 Established
bird>

Patch is in attachment.
Post by Dean Belev
Hi there,
Is the patch for 1.3.4 (http://marc.info/?l=bird-users&m=132155489919052&w=2
<http://marc.info/?l=bird-users&m=132155489919052&w=2>) usable for 1.3.6 ?
We have a strange behavior when we tried to implement it for 1.3.6 - the
process stops right after the Enter is triggered.
But the "?" function works correctly.
Best~
--
Dean Belev
Network Management Team
Neterra Ltd.
Sofia, Bulgaria
Phone:  +359 2 974 33 11
Fax:    +359 2 975 34 36
Mobile: +359 886 663 123
http://www.neterra.net
Dean Belev
2012-02-23 15:06:28 UTC
Permalink
Hi,

Thank you for the replay.
We made it also - sorry about the early bird.

Best~
Post by nirn
Hi
I adapted this the patch to the version 1.3.6,
So far I have no problems and works as shown
BIRD 1.3.6 ready.
bird> show bgp summary
Peer
AS Last state change Prefixes rcvd/best State/Last error
xx.xx.xx.xx
AS123 1329781999 392881/2358 Established
xx.xx.xx.xx
AS123 1329737563 390544/390544 Established
bird>
Patch is in attachment.
Post by Dean Belev
Hi there,
Is the patch for 1.3.4 (http://marc.info/?l=bird-users&m=132155489919052&w=2
<http://marc.info/?l=bird-users&m=132155489919052&w=2>) usable for 1.3.6 ?
We have a strange behavior when we tried to implement it for 1.3.6 - the
process stops right after the Enter is triggered.
But the "?" function works correctly.
Best~
--
Dean Belev
Network Management Team
Neterra Ltd.
Sofia, Bulgaria
Phone: +359 2 974 33 11
Fax: +359 2 975 34 36
Mobile: +359 886 663 123
http://www.neterra.net
--
Dean Belev
Network Management Team
Neterra Ltd.
Sofia, Bulgaria
Phone: +359 2 974 33 11
Fax: +359 2 975 34 36
Mobile: +359 886 663 123
http://www.neterra.net
Alexander Shikoff
2012-02-25 13:33:13 UTC
Permalink
Post by Dean Belev
Hi there,
Is the patch for 1.3.4
(http://marc.info/?l=bird-users&m=132155489919052&w=2
<http://marc.info/?l=bird-users&m=132155489919052&w=2>) usable for 1.3.6 ?
We have a strange behavior when we tried to implement it for 1.3.6 - the
process stops right after the Enter is triggered.
But the "?" function works correctly.
Old patch does not fit the source code and bird architecture as well.
I've changed it in order to more comply to a birdc syntax.

Two new patches for 1.3.6 version (bird and bird6) are attached.
They differ just in output format. Output for bird6 is two-line.




Examples:

# birdc6
BIRD 1.3.6 ready.
bird> show protocols
name proto table state since info
device1 Device master up 2012-02-25 15:04:37
ITCONSULTING BGP master up 2012-02-25 15:15:52 Established
CITYNET BGP master start 2012-02-25 15:04:37 Passive
bird> show protocols bgp
Peer
AS Last state change Prefixes rcvd/best State/Last error
2001:7f8:63::11
25372 2012-02-25 15:15:52 1/1 Established
2001:7f8:63::39
16066 2012-02-25 15:04:37 0/0 Passive
bird> show protocols bgp CITYNET
Peer
AS Last state change Prefixes rcvd/best State/Last error
2001:7f8:63::39
16066 2012-02-25 15:04:37 0/0 Passive





# birdc
BIRD 1.3.6 ready.
bird> show bgp summ
No such command. Press `?' for help.
bird> show protocols bgp
Peer AS Last state change Prefixes rcvd/best State/Last error
193.25.180.17 25372 2012-02-25 14:39:35 2/2 Established
--
MINO-RIPE
Ondrej Zajicek
2012-02-27 10:41:53 UTC
Permalink
Post by Alexander Shikoff
Post by Dean Belev
Hi there,
Is the patch for 1.3.4
(http://marc.info/?l=bird-users&m=132155489919052&w=2
<http://marc.info/?l=bird-users&m=132155489919052&w=2>) usable for 1.3.6 ?
We have a strange behavior when we tried to implement it for 1.3.6 - the
process stops right after the Enter is triggered.
But the "?" function works correctly.
Old patch does not fit the source code and bird architecture as well.
I've changed it in order to more comply to a birdc syntax.
To fit better with BIRD architecture, it would be perhaps better to
remove that from hooks and global code and move it completely to BGP
code (like 'show ospf' is in OSPF code) and name it something like
'show bgp summary'.
--
Elen sila lumenn' omentielvo

Ondrej 'SanTiago' Zajicek (email: ***@crfreenet.org)
OpenPGP encrypted e-mails preferred (KeyID 0x11DEADC3, wwwkeys.pgp.net)
"To err is human -- to blame it on a computer is even more so."
Alexander Shikoff
2012-02-27 17:31:03 UTC
Permalink
Hello List,
Post by Ondrej Zajicek
Post by Alexander Shikoff
Post by Dean Belev
Hi there,
Is the patch for 1.3.4
(http://marc.info/?l=bird-users&m=132155489919052&w=2
<http://marc.info/?l=bird-users&m=132155489919052&w=2>) usable for 1.3.6 ?
We have a strange behavior when we tried to implement it for 1.3.6 - the
process stops right after the Enter is triggered.
But the "?" function works correctly.
Old patch does not fit the source code and bird architecture as well.
I've changed it in order to more comply to a birdc syntax.
To fit better with BIRD architecture, it would be perhaps better to
remove that from hooks and global code and move it completely to BGP
code (like 'show ospf' is in OSPF code) and name it something like
'show bgp summary'.
Yes, you're right. I'm going to modify a patch, but I'm wondering
what is the best way to get a list of all BGP protocols?

The only way I know at a moment is just walking through proto_list
and comparing proto name to "BGP". Is there a better way?

Thanks in advance!
--
MINO-RIPE
Alexander V. Chernikov
2012-02-27 18:07:26 UTC
Permalink
Post by Alexander Shikoff
Hello List,
Post by Ondrej Zajicek
Post by Alexander Shikoff
Post by Dean Belev
Hi there,
Is the patch for 1.3.4
(http://marc.info/?l=bird-users&m=132155489919052&w=2
<http://marc.info/?l=bird-users&m=132155489919052&w=2>) usable for 1.3.6 ?
We have a strange behavior when we tried to implement it for 1.3.6 - the
process stops right after the Enter is triggered.
But the "?" function works correctly.
Old patch does not fit the source code and bird architecture as well.
I've changed it in order to more comply to a birdc syntax.
To fit better with BIRD architecture, it would be perhaps better to
remove that from hooks and global code and move it completely to BGP
code (like 'show ospf' is in OSPF code) and name it something like
'show bgp summary'.
Yes, you're right. I'm going to modify a patch, but I'm wondering
what is the best way to get a list of all BGP protocols?
The only way I know at a moment is just walking through proto_list
and comparing proto name to "BGP". Is there a better way?
You have to walk through all protocols, yes. However, comparison is a
bit simpler. You can take a look into bgp_incoming_connection() for more
details.
Post by Alexander Shikoff
Thanks in advance!
Alexander Shikoff
2012-02-28 10:35:39 UTC
Permalink
Hello!
Post by Alexander V. Chernikov
Post by Alexander Shikoff
Hello List,
Post by Ondrej Zajicek
Post by Alexander Shikoff
Post by Dean Belev
Hi there,
Is the patch for 1.3.4
(http://marc.info/?l=bird-users&m=132155489919052&w=2
<http://marc.info/?l=bird-users&m=132155489919052&w=2>) usable for 1.3.6 ?
We have a strange behavior when we tried to implement it for 1.3.6 - the
process stops right after the Enter is triggered.
But the "?" function works correctly.
Old patch does not fit the source code and bird architecture as well.
I've changed it in order to more comply to a birdc syntax.
To fit better with BIRD architecture, it would be perhaps better to
remove that from hooks and global code and move it completely to BGP
code (like 'show ospf' is in OSPF code) and name it something like
'show bgp summary'.
Yes, you're right. I'm going to modify a patch, but I'm wondering
what is the best way to get a list of all BGP protocols?
The only way I know at a moment is just walking through proto_list
and comparing proto name to "BGP". Is there a better way?
You have to walk through all protocols, yes. However, comparison is a
bit simpler. You can take a look into bgp_incoming_connection() for more
details.
Thank you Ondrej and Alexander for pointing me.
Universal patch for both IPv4 and IPv6 sources is attached.
Reviews and comments are kindly appreciated.


Example outputs:

# birdc6
BIRD 1.3.6 ready.
bird> show protocols
name proto table state since info
device1 Device master up 2012-02-28 12:29:44
ITCONSULTING BGP master up 2012-02-28 12:30:16 Established
CITYNET BGP master start 2012-02-28 12:29:44 Passive
bird> show bgp ?
show bgp summary [<name>] Show BGP peers summary
bird> show bgp summary CITYNET
Peer
AS Last state change Prefixes rcvd/best State/Last error
2001:7f8:63::39
16066 2012-02-28 12:29:43 0/0 Passive
bird> show bgp summary
Peer
AS Last state change Prefixes rcvd/best State/Last error
2001:7f8:63::11
25372 2012-02-28 12:30:15 1/1 Established
2001:7f8:63::39
16066 2012-02-28 12:29:43 0/0 Passive
bird>


# birdc
BIRD 1.3.6 ready.
bird> show protocols
name proto table state since info
device1 Device master up 2012-02-28 12:31:44
ITCONS BGP master up 2012-02-28 12:33:00 Established
UOS BGP master start 2012-02-28 12:33:29 Passive Received: Peer de-configured
BOOM Static master up 2012-02-28 12:31:44
bird> show bgp summary BOOM
BOOM: Not a BGP protocol
bird> show bgp summary ITCONS
Peer AS Last state change Prefixes rcvd/best State/Last error
193.25.180.17 25372 2012-02-28 12:33:00 2/2 Established
bird> show bgp summary
Peer AS Last state change Prefixes rcvd/best State/Last error
193.25.180.17 25372 2012-02-28 12:33:00 2/2 Established
193.25.180.26 42546 2012-02-28 12:33:29 0/0 Passive Received: Peer de-configured
bird>
--
MINO-RIPE
Alexander V. Chernikov
2012-03-06 18:14:21 UTC
Permalink
Post by Alexander Shikoff
Hello!
Post by Alexander V. Chernikov
Post by Alexander Shikoff
Hello List,
Post by Ondrej Zajicek
Post by Alexander Shikoff
Post by Dean Belev
Hi there,
Is the patch for 1.3.4
(http://marc.info/?l=bird-users&m=132155489919052&w=2
<http://marc.info/?l=bird-users&m=132155489919052&w=2>) usable for 1.3.6 ?
We have a strange behavior when we tried to implement it for 1.3.6 - the
process stops right after the Enter is triggered.
But the "?" function works correctly.
Old patch does not fit the source code and bird architecture as well.
I've changed it in order to more comply to a birdc syntax.
To fit better with BIRD architecture, it would be perhaps better to
remove that from hooks and global code and move it completely to BGP
code (like 'show ospf' is in OSPF code) and name it something like
'show bgp summary'.
Yes, you're right. I'm going to modify a patch, but I'm wondering
what is the best way to get a list of all BGP protocols?
The only way I know at a moment is just walking through proto_list
and comparing proto name to "BGP". Is there a better way?
You have to walk through all protocols, yes. However, comparison is a
bit simpler. You can take a look into bgp_incoming_connection() for more
details.
Thank you Ondrej and Alexander for pointing me.
Universal patch for both IPv4 and IPv6 sources is attached.
Reviews and comments are kindly appreciated.
bird is based on protocol instances and it its reasonable to name
protocols explicitly in config file.
'show bgp sum proto' gives us mapping for proto -> peer address, but
what about reverse mapping?

Like this:
bird> show bgp summary
Proto Peer AS Last state change Prefixes
rcvd/best State/Last error
b_7204 10.2.33.4 65001 22:00 0/0
Idle Received: No supported AFI/SAFI
b_7206 10.2.33.6 65001 22:00 8/3
Established
b_mega 10.0.0.1 42678 22:00 0/0
Connect

The rest of the patch is fine (to me).

P.S.
I've changed style a bit, new version attached.
Post by Alexander Shikoff
# birdc6
BIRD 1.3.6 ready.
bird> show protocols
name proto table state since info
device1 Device master up 2012-02-28 12:29:44
ITCONSULTING BGP master up 2012-02-28 12:30:16 Established
CITYNET BGP master start 2012-02-28 12:29:44 Passive
bird> show bgp ?
show bgp summary [<name>] Show BGP peers summary
bird> show bgp summary CITYNET
Peer
AS Last state change Prefixes rcvd/best State/Last error
2001:7f8:63::39
16066 2012-02-28 12:29:43 0/0 Passive
bird> show bgp summary
Peer
AS Last state change Prefixes rcvd/best State/Last error
2001:7f8:63::11
25372 2012-02-28 12:30:15 1/1 Established
2001:7f8:63::39
16066 2012-02-28 12:29:43 0/0 Passive
bird>
# birdc
BIRD 1.3.6 ready.
bird> show protocols
name proto table state since info
device1 Device master up 2012-02-28 12:31:44
ITCONS BGP master up 2012-02-28 12:33:00 Established
UOS BGP master start 2012-02-28 12:33:29 Passive Received: Peer de-configured
BOOM Static master up 2012-02-28 12:31:44
bird> show bgp summary BOOM
BOOM: Not a BGP protocol
bird> show bgp summary ITCONS
Peer AS Last state change Prefixes rcvd/best State/Last error
193.25.180.17 25372 2012-02-28 12:33:00 2/2 Established
bird> show bgp summary
Peer AS Last state change Prefixes rcvd/best State/Last error
193.25.180.17 25372 2012-02-28 12:33:00 2/2 Established
193.25.180.26 42546 2012-02-28 12:33:29 0/0 Passive Received: Peer de-configured
bird>
Alexander Shikoff
2012-03-06 20:33:50 UTC
Permalink
Post by Alexander V. Chernikov
'show bgp sum proto' gives us mapping for proto -> peer address, but
what about reverse mapping?
bird> show bgp summary
Proto Peer AS Last state change Prefixes
rcvd/best State/Last error
b_7204 10.2.33.4 65001 22:00 0/0
Idle Received: No supported AFI/SAFI
b_7206 10.2.33.6 65001 22:00 8/3
Established
b_mega 10.0.0.1 42678 22:00 0/0
Connect
The only reason why I've not included instance name in output
is the urge to minimize it. It's easy to implement, if someone
really needs instance name in an output.
Post by Alexander V. Chernikov
P.S.
I've changed style a bit, new version attached.
+void
+bgp_sh_summary(struct symbol *sym)
+{
+ struct proto_config *pc = NULL;
+
+ if (sym)
+ {
+ if (sym->class != SYM_PROTO)
+ cf_error("%s: Not a protocol", sym->name);
+ pc = (struct proto_config *)sym->def;
+ if (pc->protocol != &proto_bgp)
+ cf_error("%s: Not a BGP protocol", sym->name);
+ }
+ else
+ {
+ if (EMPTY_LIST(config->protos))
+ {
+ cli_msg(1006, "No protocols match");
+ return;
+ }
+ }
In this case EMPTY_LIST will be applied to global protos list. Thus if
you have only non-BGP protos then EMPTY_LIST(config->protos) will return 0
Post by Alexander V. Chernikov
+
+#ifdef IPV6
+ cli_msg(-2002, "%-10s %s\n%12s %-19s %-20s %s", "Proto", "Peer", "AS", "Last state change", "Prefixes rcvd/best", "State/Last error" );
+#else
+ cli_msg(-2002, "%-10s %-15s %10s %-19s %-20s %s", "Proto", "Peer", "AS", "Last state change", "Prefixes rcvd/best", "State/Last error" );
+#endif
... and nothing after it. I tried to avoid that.
Post by Alexander V. Chernikov
+ if (pc)
+ {
+ /* Show single protocol info */
+ bgp_sh_proto_summary(pc->proto);
+ cli_msg(0, "");
+ return;
+ }
+
+ WALK_LIST(pc, config->protos)
+ {
+ if ((pc->protocol != &proto_bgp) || (!pc->proto))
+ continue;
+
+ bgp_sh_proto_summary(pc->proto);
+ }
+
+ cli_msg(0, "");
+}
--
MINO-RIPE
Alexander V. Chernikov
2012-03-07 10:54:51 UTC
Permalink
Post by Alexander Shikoff
'show bgp sum proto' gives us mapping for proto -> peer address, but
what about reverse mapping?
bird> show bgp summary
Proto Peer AS Last state change Prefixes
rcvd/best State/Last error
b_7204 10.2.33.4 65001 22:00 0/0
Idle Received: No supported AFI/SAFI
b_7206 10.2.33.6 65001 22:00 8/3
Established
b_mega 10.0.0.1 42678 22:00 0/0
Connect
The only reason why I've not included instance name in output
is the urge to minimize it. It's easy to implement, if someone
really needs instance name in an output.
Ok, so I vote for including protocol name to final version :)
Post by Alexander Shikoff
P.S.
I've changed style a bit, new version attached.
+void
+bgp_sh_summary(struct symbol *sym)
+{
+ struct proto_config *pc = NULL;
+
+ if (sym)
+ {
+ if (sym->class != SYM_PROTO)
+ cf_error("%s: Not a protocol", sym->name);
+ pc = (struct proto_config *)sym->def;
+ if (pc->protocol !=&proto_bgp)
+ cf_error("%s: Not a BGP protocol", sym->name);
+ }
+ else
+ {
+ if (EMPTY_LIST(config->protos))
+ {
+ cli_msg(1006, "No protocols match");
+ return;
+ }
+ }
In this case EMPTY_LIST will be applied to global protos list. Thus if
you have only non-BGP protos then EMPTY_LIST(config->protos) will return 0
It seems sometimes it is better just go to sleep instead of writing
patches :)

However, we can still define cli_msg as print_header macro before
bgp_sh_summary() not to write it twice.
Post by Alexander Shikoff
+
+#ifdef IPV6
+ cli_msg(-2002, "%-10s %s\n%12s %-19s %-20s %s", "Proto", "Peer", "AS", "Last state change", "Prefixes rcvd/best", "State/Last error" );
+#else
+ cli_msg(-2002, "%-10s %-15s %10s %-19s %-20s %s", "Proto", "Peer", "AS", "Last state change", "Prefixes rcvd/best", "State/Last error" );
+#endif
... and nothing after it. I tried to avoid that.
+ if (pc)
+ {
+ /* Show single protocol info */
+ bgp_sh_proto_summary(pc->proto);
+ cli_msg(0, "");
+ return;
+ }
+
+ WALK_LIST(pc, config->protos)
+ {
+ if ((pc->protocol !=&proto_bgp) || (!pc->proto))
+ continue;
+
+ bgp_sh_proto_summary(pc->proto);
+ }
+
+ cli_msg(0, "");
+}
Alexander Shikov
2012-03-14 12:19:43 UTC
Permalink
Hello List,
Post by Alexander V. Chernikov
Post by Alexander Shikoff
'show bgp sum proto' gives us mapping for proto -> peer address, but
what about reverse mapping?
bird> show bgp summary
Proto Peer AS Last state change Prefixes
rcvd/best State/Last error
b_7204 10.2.33.4 65001 22:00 0/0
Idle Received: No supported AFI/SAFI
b_7206 10.2.33.6 65001 22:00 8/3
Established
b_mega 10.0.0.1 42678 22:00 0/0
Connect
The only reason why I've not included instance name in output
is the urge to minimize it. It's easy to implement, if someone
really needs instance name in an output.
Ok, so I vote for including protocol name to final version :)
Maybe we should make this feature configurable?
--
Alexander Shikov
Technical Staff, Digital Telecom IX
Alexander V. Chernikov
2012-03-14 23:45:56 UTC
Permalink
Post by Alexander Shikoff
Hello List,
Post by Alexander V. Chernikov
Post by Alexander Shikoff
'show bgp sum proto' gives us mapping for proto -> peer address, but
what about reverse mapping?
bird> show bgp summary
Proto Peer AS Last state change Prefixes
rcvd/best State/Last error
b_7204 10.2.33.4 65001 22:00 0/0
Idle Received: No supported AFI/SAFI
b_7206 10.2.33.6 65001 22:00 8/3
Established
b_mega 10.0.0.1 42678 22:00 0/0
Connect
The only reason why I've not included instance name in output
is the urge to minimize it. It's easy to implement, if someone
really needs instance name in an output.
Ok, so I vote for including protocol name to final version :)
Maybe we should make this feature configurable?
Maybe 'sh ip b sum [verbose]' to retain both ? :)
Loading...