Skip to content

Add support for registry scoped ASNs - #134

Open
jwbensley wants to merge 1 commit into
bgp:mainfrom
jwbensley:support-scoped-asns
Open

jwbensley wants to merge 1 commit into
bgp:mainfrom
jwbensley:support-scoped-asns

Conversation

@jwbensley

Copy link
Copy Markdown
Contributor

Add support for parsing registry scoped ASNs such as RIPE::AS41695 to bgpq4.

Existing behaviour:

$ which bgpq4
/usr/bin/bgpq4

$ /usr/bin/bgpq4 -v
bgpq4 - a versatile utility to generate BGP filters
version: 1.4
website: https://github.com/bgp/bgpq4
maintainer: Job Snijders <job@sobornost.net>

# Without a source prefix all data sources are used:

$ /usr/bin/bgpq4 -d AS41695
DEBUG: expander.c:908 bgpq_expand Acquired sendbuf of 4608 bytes
DEBUG: expander.c:929 bgpq_expand Sending '!!' to server to request for the connection to remain open
DEBUG: expander.c:938 bgpq_expand b->identify: Sending '!n bgpq4 1.4' to server.
DEBUG: expander.c:951 bgpq_expand Got answer C
DEBUG: expander.c:397 bgpq_pipeline expander: sending !gas41695
no ip prefix-list NN
ip prefix-list NN permit 89.21.224.0/19
ip prefix-list NN permit 134.0.64.0/21

# Specifying a source prefix is not currently supported

$ /usr/bin/bgpq4 -d RIPE::AS41695
ERROR:Unable to parse prefix 'RIPE::AS41695', af=10 (inet6), ret=0
ERROR:Unable to parse prefix RIPE::AS41695
ERROR:Unable to add prefix RIPE::AS41695 (bad prefix or address-family)

PR behaviour:

# When no source prefix is specified, the server source is set to all (effectively no change)

$ ./bgpq4 -d AS41695
DEBUG: expander.c:1094 bgpq_expand Sending '!!' to server to request for the connection to remain open
DEBUG: expander.c:1104 bgpq_expand b->identify: Sending '!n bgpq4 1.16' to server.
DEBUG: expander.c:1118 bgpq_expand Got answer C
DEBUG: expander.c:457 bgpq_get_irrd_sources Requesting source list !s-lc
DEBUG: expander.c:468 bgpq_get_irrd_sources Got answer A127
NTTCOM,INTERNAL,LACNIC,RADB,RIPE,RIPE-NONAUTH,ALTDB,BELL,LEVEL3,APNIC,JPIRR,ARIN,BBOI,TC,AFRINIC,IDNIC,RPKI,REGISTROBR,CANARIE
C
DEBUG: expander.c:560 bgpq_pipeline expander: sending !sNTTCOM,INTERNAL,LACNIC,RADB,RIPE,RIPE-NONAUTH,ALTDB,BELL,LEVEL3,APNIC,JPIRR,ARIN,BBOI,TC,AFRINIC,IDNIC,RPKI,REGISTROBR,CANARIE
DEBUG: expander.c:835 bgpq_read No data expanding !sNTTCOM,INTERNAL,LACNIC,RADB,RIPE,RIPE-NONAUTH,ALTDB,BELL,LEVEL3,APNIC,JPIRR,ARIN,BBOI,TC,AFRINIC,IDNIC,RPKI,REGISTROBR,CANARIE
DEBUG: expander.c:560 bgpq_pipeline expander: sending !gas41695
no ip prefix-list NN
ip prefix-list NN permit 89.21.224.0/19
ip prefix-list NN permit 134.0.64.0/21


# When source prefix is specified, source is used:

$ ./bgpq4 -d RIPE::AS41695
DEBUG: expander.c:1094 bgpq_expand Sending '!!' to server to request for the connection to remain open
DEBUG: expander.c:1104 bgpq_expand b->identify: Sending '!n bgpq4 1.16' to server.
DEBUG: expander.c:1118 bgpq_expand Got answer C
DEBUG: expander.c:457 bgpq_get_irrd_sources Requesting source list !s-lc
DEBUG: expander.c:468 bgpq_get_irrd_sources Got answer A127
NTTCOM,INTERNAL,LACNIC,RADB,RIPE,RIPE-NONAUTH,ALTDB,BELL,LEVEL3,APNIC,JPIRR,ARIN,BBOI,TC,AFRINIC,IDNIC,RPKI,REGISTROBR,CANARIE
C
DEBUG: expander.c:560 bgpq_pipeline expander: sending !sNTTCOM,INTERNAL,LACNIC,RADB,RIPE,RIPE-NONAUTH,ALTDB,BELL,LEVEL3,APNIC,JPIRR,ARIN,BBOI,TC,AFRINIC,IDNIC,RPKI,REGISTROBR,CANARIE
DEBUG: expander.c:835 bgpq_read No data expanding !sNTTCOM,INTERNAL,LACNIC,RADB,RIPE,RIPE-NONAUTH,ALTDB,BELL,LEVEL3,APNIC,JPIRR,ARIN,BBOI,TC,AFRINIC,IDNIC,RPKI,REGISTROBR,CANARIE
DEBUG: expander.c:560 bgpq_pipeline expander: sending !sRIPE
DEBUG: expander.c:560 bgpq_pipeline expander: sending !gas41695
DEBUG: expander.c:835 bgpq_read No data expanding !sRIPE
no ip prefix-list NN
ip prefix-list NN permit 89.21.224.0/19
ip prefix-list NN permit 134.0.64.0/21

I've updated the unit tests to check this new functionality, and documented it the README.

@job

job commented Sep 1, 2026

Copy link
Copy Markdown
Member

Thanks! Will test a bit and then plan to merge

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.

2 participants