Skip to content

Conversation

@kalash-nexthop
Copy link
Contributor

Currently SONiC doesn't allow configuring external BMP collector, and instead relies on hard-coded local BMP collector config with only pre-policy support. Making this generic so that a user can set potentially multiple external collectors with multiple policies, as FRR already supports this.

Instead of just creating a PR with yang model, I added the vtysh cmd conversion stuff to this PR, so that I can demonstrate the model and corresponding vtysh config that's already supported in FRR.

fixes #24962

Why I did it

Currently SONiC doesn't allow configuring external BMP collector, and instead relies on hard-coded local BMP collector config with only pre-policy support. But some customers want to use external collectors with both pre and post policy config.

Work item tracking
  • Microsoft ADO (number only):

How I did it

1- Extended sonic-bmp.yang YANG model to include BMP collector (potentially multiple collectors) configuration parameters: IP, port, stats interval, retry intervals, monitor policies.
2- The new yang model is similar to FRR's bmp yang model, but instead of using nested lists, it does below (3) so that SONiC's yang parser doesn't complain.
3- The model to allow multiple targets and collectors is similar to how BGP_NEIGHBOR container block is used for defining the neighbors, and then another BGP_NEIGHBOR_AF container to define afi-safis on those neighbors. I've verified that yang validation works for this.
4- Updated unified/separated mode templates (bgpd.conf.db.j2 and bgpd.main.conf.j2) to use BMP configuration from CONFIG_DB with fallback to default values
5- Added BMP handler in frrcfgd.py to dynamically convert CONFIG_DB BMP changes to vtysh commands for runtime configuration updates
6- Supports multiple configurable monitor policies per target: pre-policy, post-policy, loc-rib
7- Default collector IP is 127.0.0.1 when not specified to maintain backward compatibility

A sample yang model based on the new changes, showing multiple targets, multiple collectors per target, multiple afi-safis per target and multiple policies per afi-safi:

{
    "BMP_TARGET": {
        "production": {
            "mirror": "true",
            "stats-interval": "5000"
        },
        "monitoring": {
            "mirror": "false",
            "stats-interval": "10000"
        },
        "backup": {
            "mirror": "true",
            "stats-interval": "3000"
        }
    },
    "BMP_TARGET_COLLECTOR": {
        "production|192.168.1.100|5000": {
            "min-retry": "30000",
            "max-retry": "720000"
        },
        "production|192.168.1.101|5001": {
            "min-retry": "20000",
            "max-retry": "600000"
        },
        "monitoring|10.0.0.50|6000": {
            "min-retry": "15000",
            "max-retry": "300000"
        },
        "monitoring|10.0.0.51|6001": {
            "min-retry": "15000",
            "max-retry": "300000"
        },
        "backup|172.16.0.10|7000": {
            "min-retry": "10000",
            "max-retry": "180000"
        }
    },
    "BMP_TARGET_AFI_SAFI": {
        "production|ipv4_unicast": {
            "adj-rib-in-pre": "true",
            "adj-rib-in-post": "true",
            "loc-rib": "true"
        },
        "production|ipv6_unicast": {
            "adj-rib-in-pre": "true",
            "adj-rib-in-post": "false",
            "loc-rib": "true"
        },
        "production|l2vpn_evpn": {
            "adj-rib-in-pre": "false",
            "adj-rib-in-post": "true",
            "loc-rib": "false"
        },
        "monitoring|ipv4_unicast": {
            "adj-rib-in-pre": "true",
            "adj-rib-in-post": "false",
            "loc-rib": "false"
        },
        "monitoring|ipv6_unicast": {
            "adj-rib-in-pre": "true",
            "adj-rib-in-post": "false",
            "loc-rib": "false"
        },
        "backup|ipv4_unicast": {
            "adj-rib-in-pre": "true",
            "adj-rib-in-post": "true",
            "loc-rib": "true"
        }
    }
}

And corresponding vtysh commands in vtysh -c "show running-config"

router bgp 65100
 !
 bmp targets production
  bmp stats interval 5000
  bmp mirror
  bmp monitor ipv4 unicast pre-policy
  bmp monitor ipv4 unicast post-policy
  bmp monitor ipv4 unicast loc-rib
  bmp monitor ipv6 unicast pre-policy
  bmp monitor ipv6 unicast loc-rib
  bmp monitor l2vpn evpn post-policy
  bmp connect 192.168.1.100 port 5000 min-retry 30000 max-retry 720000
  bmp connect 192.168.1.101 port 5001 min-retry 20000 max-retry 600000
 exit
 !
 bmp targets monitoring
  bmp stats interval 10000
  bmp monitor ipv4 unicast pre-policy
  bmp monitor ipv6 unicast pre-policy
  bmp connect 10.0.0.50 port 6000 min-retry 15000 max-retry 300000
  bmp connect 10.0.0.51 port 6001 min-retry 15000 max-retry 300000
 exit
 !
 bmp targets backup
  bmp stats interval 3000
  bmp mirror
  bmp monitor ipv4 unicast pre-policy
  bmp monitor ipv4 unicast post-policy
  bmp monitor ipv4 unicast loc-rib
  bmp connect 172.16.0.10 port 7000 min-retry 10000 max-retry 180000
 exit
 !
exit
!

How to verify it

  • Manually verified the generated vtysh config for above yang model in config_db.json in both separated and unified mode by doing config reload.
  • Manually verified the dynamic vtysh config generation by frrcfgd.py for above
  • Manually verified that config reload as well as config replace don't complain of yang validation failure for above model.

Which release branch to backport (provide reason below if selected)

  • 202305
  • 202311
  • 202405
  • 202411
  • 202505
  • 202511

Tested branch (Please provide the tested image version)

Description for the changelog

Link to config_db schema for YANG module changes

A picture of a cute animal (not mandatory but encouraged)

@mssonicbld
Copy link
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

…ially multiple collectors) configuration parameters: IP, port, stats interval, retry intervals, monitor policies.

- Updated unified/separated mode templates (bgpd.conf.db.j2 and bgpd.main.conf.j2) to use BMP configuration from CONFIG_DB with fallback to default values
- Added BMP handler in frrcfgd.py to dynamically convert CONFIG_DB BMP changes to vtysh commands for runtime configuration updates
- Supports multiple configurable monitor policies per target: pre-policy, post-policy, loc-rib
- Default collector IP is 127.0.0.1 when not specified to maintain backward compatibility

Signed-off-by: Kalash Nainwal <kalash@nexthop.ai>
@mssonicbld
Copy link
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enhancement: Allow streaming BMP events to an external BMP collector

2 participants