]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
BMP: Add local address option
authorMichal Zagorski <mzagorsk@akamai.com>
Tue, 30 May 2023 15:09:25 +0000 (17:09 +0200)
committerOndrej Zajicek <santiago@crfreenet.org>
Tue, 30 May 2023 15:09:25 +0000 (17:09 +0200)
Also remove unused local and ip_post_policy options.

Co-authored with Pawel Maslanka <pmaslank@akamai.com>.

Minor changes by committer.

proto/bmp/bmp.c
proto/bmp/bmp.h
proto/bmp/config.Y

index ca508049d31973a00e95d3675461edd7052e47ac..7efa8f6a343b4fb773e6da3d994a7f36d9d655fc 100644 (file)
@@ -892,6 +892,7 @@ bmp_connect(struct bmp_proto *p)
 
   sock *sk = sk_new(p->p.pool);
   sk->type = SK_TCP_ACTIVE;
+  sk->saddr = p->local_addr;
   sk->daddr = p->station_ip;
   sk->dport = p->station_port;
   sk->ttl = IP4_MAX_TTL;
@@ -970,26 +971,26 @@ bmp_init(struct proto_config *CF)
   struct proto *P = proto_new(CF);
   struct bmp_proto *p = (void *) P;
   struct bmp_config *cf = (void *) CF;
-
   p->cf = cf;
+  p->local_addr = cf->local_addr;
   p->station_ip = cf->station_ip;
   p->station_port = cf->station_port;
   strcpy(p->sys_descr, cf->sys_descr);
   strcpy(p->sys_name, cf->sys_name);
   p->monitoring_rib.in_pre_policy = cf->monitoring_rib_in_pre_policy;
-  p->monitoring_rib.in_post_policy = cf->monitoring_rib_in_post_policy;
-  p->monitoring_rib.local = cf->monitoring_rib_local;
 
   return P;
 }
 
+/**
+ * bmp_start - initialize internal resources of BMP implementation.
+ * NOTE: It does not connect to BMP collector yet.
+ */
 static int
 bmp_start(struct proto *P)
 {
   struct bmp_proto *p = (void *) P;
 
-  log(L_DEBUG "Init BMP");
-
   p->buffer_mpool = rp_new(P->pool, "BMP Buffer");
   p->map_mem_pool = rp_new(P->pool, "BMP Map");
   p->tx_mem_pool = rp_new(P->pool, "BMP Tx");
index 40d42e6a4bb070cb035e740adefbfd2d33ab23f9..6d429e66741d7ffc3911235f74768cd30a72e9e7 100644 (file)
@@ -35,11 +35,10 @@ struct bmp_config {
   struct proto_config c;
   const char *sys_descr;              // sysDescr MIB-II [RFC1213] object
   const char *sys_name;               // sysName MIB-II [RFC1213] object
+  ip_addr local_addr;                 // Local IP address
   ip_addr station_ip;                 // Monitoring station address
   u16 station_port;                   // Monitoring station TCP port
   bool monitoring_rib_in_pre_policy;  // Route monitoring pre-policy Adj-Rib-In
-  bool monitoring_rib_in_post_policy; // Route monitoring post-policy Adj-Rib-In
-  bool monitoring_rib_local;          // Route monitoring Local Rib
 };
 
 /* Forward declarations */
@@ -59,9 +58,10 @@ struct bmp_proto {
   struct proto p;                  // Parent proto
   const struct bmp_config *cf;     // Shortcut to BMP configuration
   sock *sk;                        // TCP connection
-  event *tx_ev;                           // TX event
+  event *tx_ev;                    // TX event
   char sys_descr[MIB_II_STR_LEN];  // sysDescr MIB-II [RFC1213] object
   char sys_name[MIB_II_STR_LEN];   // sysName MIB-II [RFC1213] object
+  ip_addr local_addr;              // Source local IP address
   ip_addr station_ip;              // Monitoring station IP address
   u16 station_port;                // Monitoring station TCP port
   struct monitoring_rib monitoring_rib;
index 776d7ecc154561207d3800f851d091b60cc69922..2fc8745816ab71ce7527f3dc14572c285c271bdc 100644 (file)
@@ -25,13 +25,12 @@ proto: bmp_proto '}' ;
 
 bmp_proto_start: proto_start BMP {
      this_proto = proto_config_new(&proto_bmp, $1);
+     BMP_CFG->local_addr = IPA_NONE4;
      BMP_CFG->station_ip = IPA_NONE4;
      BMP_CFG->station_port = 0;
      BMP_CFG->sys_descr = "Not defined";
      BMP_CFG->sys_name = "Not defined";
      BMP_CFG->monitoring_rib_in_pre_policy = false;
-     BMP_CFG->monitoring_rib_in_post_policy = false;
-     BMP_CFG->monitoring_rib_local = false;
    }
  ;
 
@@ -52,6 +51,9 @@ bmp_station_address:
 bmp_proto:
    bmp_proto_start proto_name '{'
  | bmp_proto proto_item ';'
+ | bmp_proto LOCAL ADDRESS ipa ';' {
+     BMP_CFG->local_addr = $4;
+   }
  | bmp_proto STATION ADDRESS bmp_station_address ';'
  | bmp_proto SYSTEM DESCRIPTION text ';' {
      if (!$4 || (strlen($4) == 0))
@@ -70,12 +72,6 @@ bmp_proto:
  | bmp_proto MONITORING RIB IN PRE_POLICY bool ';' {
      BMP_CFG->monitoring_rib_in_pre_policy = $6;
    }
- | bmp_proto MONITORING RIB IN POST_POLICY bool ';' {
-     BMP_CFG->monitoring_rib_in_post_policy = $6;
-   }
- | bmp_proto MONITORING RIB LOCAL bool ';' {
-     BMP_CFG->monitoring_rib_local = $5;
-   }
  ;
 
 CF_CODE