]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: update I/O docs
authorQuentin Young <qlyoung@cumulusnetworks.com>
Thu, 8 Jun 2017 21:47:33 +0000 (21:47 +0000)
committerQuentin Young <qlyoung@cumulusnetworks.com>
Thu, 30 Nov 2017 21:18:01 +0000 (16:18 -0500)
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
bgpd/bgp_io.c
bgpd/bgp_io.h

index e335feed91decbd2fc941d0b3ddb89c2fc745a58..eed310dec9ce48d5b91be77298fbd13f6c501b50 100644 (file)
@@ -1,6 +1,7 @@
 /* BGP I/O.
- * Implements packet I/O in a consumer pthread.
+ * Implements packet I/O in a pthread.
  * Copyright (C) 2017  Cumulus Networks
+ * Quentin Young
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -95,7 +96,8 @@ int bgp_io_stop(void **result, struct frr_pthread *fpt)
 
        return 0;
 }
-/* ------------------------------------------------------------------------ */
+
+/* Extern API -------------------------------------------------------------- */
 
 void bgp_writes_on(struct peer *peer)
 {
@@ -168,9 +170,11 @@ void bgp_reads_off(struct peer *peer)
        UNSET_FLAG(peer->thread_flags, PEER_THREAD_READS_ON);
 }
 
+/* Internal functions ------------------------------------------------------- */
+
 /**
- * Called from PTHREAD_IO when select() or poll() determines that the file
- * descriptor is ready to be written to.
+ * Called from I/O pthread when a file descriptor has become ready for writing.
+ * HUP is not handled here,
  */
 static int bgp_process_writes(struct thread *thread)
 {
@@ -209,8 +213,8 @@ static int bgp_process_writes(struct thread *thread)
 }
 
 /**
- * Called from PTHREAD_IO when select() or poll() determines that the file
- * descriptor is ready to be read from.
+ * Called from I/O pthread when a file descriptor has become ready for reading,
+ * or has hung up.
  *
  * We read as much data as possible, process as many packets as we can and
  * place them on peer->ibuf for secondary processing by the main thread.
@@ -440,9 +444,9 @@ done : {
 }
 
 /**
- * Reads <= 1 packet worth of data from peer->fd into peer->ibuf_work.
+ * Reads a chunk of data from peer->fd into peer->ibuf_work.
  *
- * @return whether a full packet was read
+ * @return status flag (see top-of-file)
  */
 static uint16_t bgp_read(struct peer *peer)
 {
index 6cda227a052c90fff59790b28810024f4e35fad2..cf5fc6fb526dc14e5006e99346325e26a1a6e085 100644 (file)
@@ -1,23 +1,22 @@
-/*
-  BGP I/O.
-  Implements a consumer thread to flush packets destined for remote peers.
-
-  Copyright (C) 2017  Cumulus Networks
-
-  This program is free software; you can redistribute it and/or modify
-  it under the terms of the GNU General Public License as published by
-  the Free Software Foundation; either version 2 of the License, or
-  (at your option) any later version.
-
-  This program is distributed in the hope that it will be useful, but
-  WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-  General Public License for more details.
-
-  You should have received a copy of the GNU General Public License
-  along with this program; see the file COPYING; if not, write to the
-  Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
-  MA 02110-1301 USA
+/* BGP I/O.
+ * Implements packet I/O in a pthread.
+ * Copyright (C) 2017  Cumulus Networks
+ * Quentin Young
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; see the file COPYING; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
+ * MA 02110-1301 USA
  */
 
 #ifndef _FRR_BGP_IO_H
@@ -64,12 +63,9 @@ extern int bgp_io_stop(void **result, struct frr_pthread *fpt);
  * Turns on packet writing for a peer.
  *
  * After this function is called, any packets placed on peer->obuf will be
- * written to peer->fd at regular intervals. Additionally it becomes unsafe to
- * use peer->fd with select() or poll().
+ * written to peer->fd until no more packets remain.
  *
- * This function increments the peer reference counter with peer_lock().
- *
- * If the peer is already registered, nothing happens.
+ * Additionally, it becomes unsafe to perform socket actions on peer->fd.
  *
  * @param peer - peer to register
  */
@@ -78,16 +74,11 @@ extern void bgp_writes_on(struct peer *peer);
 /**
  * Turns off packet writing for a peer.
  *
- * After this function is called, any packets placed on peer->obuf will not be
- * written to peer->fd. After this function returns it is safe to use peer->fd
- * with select() or poll().
- *
- * If the flush = true, a last-ditch effort will be made to flush any remaining
- * packets to peer->fd. Upon encountering any error whatsoever, the attempt
- * will abort. If the caller wishes to know whether the flush succeeded they
- * may check peer->obuf->count against zero.
+ * After this function returns, packets placed on peer->obuf will not be
+ * written to peer->fd by the I/O thread.
  *
- * If the peer is not registered, nothing happens.
+ * After this function returns it becomes safe to perform socket actions on
+ * peer->fd.
  *
  * @param peer - peer to deregister
  * @param flush - as described
@@ -98,15 +89,14 @@ extern void bgp_writes_off(struct peer *peer);
  * Turns on packet reading for a peer.
  *
  * After this function is called, any packets received on peer->fd will be read
- * and copied into the FIFO queue peer->ibuf. Additionally it becomes unsafe to
- * use peer->fd with select() or poll().
+ * and copied into the FIFO queue peer->ibuf.
  *
- * When a full packet is read, bgp_process_packet() will be scheduled on the
- * main thread.
+ * Additionally, it becomes unsafe to perform socket actions on peer->fd.
  *
- * This function increments the peer reference counter with peer_lock().
+ * Whenever one or more packets are placed onto peer->ibuf, a task of type
+ * THREAD_EVENT will be placed on the main thread whose handler is
  *
- * If the peer is already registered, nothing happens.
+ *   bgp_packet.c:bgp_process_packet()
  *
  * @param peer - peer to register
  */
@@ -116,12 +106,10 @@ extern void bgp_reads_on(struct peer *peer);
  * Turns off packet reading for a peer.
  *
  * After this function is called, any packets received on peer->fd will not be
- * read. After this function returns it is safe to use peer->fd with select()
- * or poll().
- *
- * This function decrements the peer reference counter with peer_unlock().
+ * read by the I/O thread.
  *
- * If the peer is not registered, nothing happens.
+ * After this function returns it becomes safe to perform socket actions on
+ * peer->fd.
  *
  * @param peer - peer to deregister
  */