]> git.proxmox.com Git - mirror_frr.git/commitdiff
bgpd: small optimization with UPDATE generation
authorQuentin Young <qlyoung@cumulusnetworks.com>
Thu, 30 Nov 2017 22:16:37 +0000 (17:16 -0500)
committerQuentin Young <qlyoung@cumulusnetworks.com>
Thu, 30 Nov 2017 22:17:16 +0000 (17:17 -0500)
After a batch of generated UPDATEs, call bgp_writes_on() once instead of
after generating each packet.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
bgpd/bgp_packet.c

index 2dea82fe56c247509cc077724ce7a2455a4f7fb9..e111dd785fd4bf39d84628c50c1441c6403c3ddc 100644 (file)
@@ -306,7 +306,12 @@ int bgp_nlri_parse(struct peer *peer, struct attr *attr,
        return -1;
 }
 
-/* The next action for the peer from a write perspective */
+/*
+ * Checks a variety of conditions to determine whether the peer needs to be
+ * rescheduled for packet generation again, and does so if necessary.
+ *
+ * @param peer to check for rescheduling
+ */
 static void bgp_write_proceed_actions(struct peer *peer)
 {
        afi_t afi;
@@ -356,11 +361,10 @@ static void bgp_write_proceed_actions(struct peer *peer)
        }
 }
 
-/**
- * Enqueue onto the peer's output buffer any packets which are pending for the
- * update group it is a member of.
- *
- * XXX: Severely needs performance work.
+/*
+ * Generate advertisement information (withdraws, updates, EOR) from each
+ * update group a peer belongs to, encode this information into packets, and
+ * enqueue the packets onto the peer's output buffer.
  */
 int bgp_generate_updgrp_packets(struct thread *thread)
 {
@@ -435,7 +439,6 @@ int bgp_generate_updgrp_packets(struct thread *thread)
                                                             peer, afi,
                                                             safi))) {
                                                        bgp_packet_add(peer, s);
-                                                       bgp_writes_on(peer);
                                                }
                                        }
                                }
@@ -448,11 +451,13 @@ int bgp_generate_updgrp_packets(struct thread *thread)
                         * and advance peer */
                        s = bpacket_reformat_for_peer(next_pkt, paf);
                        bgp_packet_add(peer, s);
-                       bgp_writes_on(peer);
                        bpacket_queue_advance_peer(paf);
                }
        } while (s && (++generated < wpq));
 
+       if (generated)
+               bgp_writes_on(peer);
+
        bgp_write_proceed_actions(peer);
 
        return 0;