diff options
author | kyechou | 2022-05-24 07:46:33 -0500 |
---|---|---|
committer | kyechou | 2022-05-24 07:46:33 -0500 |
commit | a557598fbdf7d80387e31ec1e022adcfc6e18054 (patch) | |
tree | 60ee1f04ed04d6dd73ad986e9411432da205b6d7 | |
parent | 7eb878fbfe68b28844fc8737c66d2cd71b82d150 (diff) | |
download | aur-bgpdump.tar.gz |
Add PR#5
-rw-r--r-- | .SRCINFO | 9 | ||||
-rw-r--r-- | 05-addr-representation.diff | 66 | ||||
-rw-r--r-- | PKGBUILD | 32 | ||||
-rw-r--r-- | updates.nlri_mask_trailing_bits.gz | bin | 0 -> 108 bytes | |||
-rw-r--r-- | updates.nlri_mask_trailing_bits.gz.bgp.gz | bin | 0 -> 102 bytes |
5 files changed, 98 insertions, 9 deletions
@@ -1,14 +1,19 @@ pkgbase = bgpdump pkgdesc = Utility and C Library for parsing MRT files pkgver = 1.6.2 - pkgrel = 1 + pkgrel = 2 url = https://github.com/RIPE-NCC/bgpdump arch = x86_64 license = GPL2 depends = zlib depends = bzip2 source = https://github.com/RIPE-NCC/bgpdump/archive/v1.6.2.tar.gz + source = 05-addr-representation.diff + source = updates.nlri_mask_trailing_bits.gz + source = updates.nlri_mask_trailing_bits.gz.bgp.gz sha256sums = 415692c173a84c48b1e927a6423a4f8fd3e6359bc3008c06b7702fe143a76223 + sha256sums = 86efd03c29add6e93596b3df8eb8a6eded67a907811e2ff61f60c8bb4ac663df + sha256sums = 19ed2d93b3dd30cbb5af3bdccf421e22b685e9944138b96a72b34660865a5607 + sha256sums = 8f71ea4caa5d22cf9e105a64be1be91a3168fd4ee6113ec2ff863cefc526b506 pkgname = bgpdump - diff --git a/05-addr-representation.diff b/05-addr-representation.diff new file mode 100644 index 000000000000..4c22c66daac7 --- /dev/null +++ b/05-addr-representation.diff @@ -0,0 +1,66 @@ +diff --git a/ChangeLog b/ChangeLog +index 8004c56..5c8a5ff 100644 +--- a/ChangeLog ++++ b/ChangeLog +@@ -8,6 +8,9 @@ PLEASE DO NOT E-MAIL INDIVIDUAL DEVELOPERS ABOUT + ISSUES, AS YOUR E-MAIL MAY BE LOST + ========================================================== + ++2020-09-20 Colin Petrie <colin@spakka.net> ++ * Mask trailing bits in NLRI to correct address representations ++ + 2020-06-07 Colin Petrie <colin@spakka.net> v1.6.2 + * Version fix and make dist + +diff --git a/bgpdump_lib.c b/bgpdump_lib.c +index d9bb65b..693ad3e 100644 +--- a/bgpdump_lib.c ++++ b/bgpdump_lib.c +@@ -1561,6 +1561,7 @@ void process_mp_withdraw(struct mstream *s, struct mp_info *info, struct zebra_i + } + + static int read_prefix_list(struct mstream *s, u_int16_t afi, struct prefix *prefixes, struct zebra_incomplete *incomplete, int is_addp) { ++ u_int8_t maskarray[8] = {0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff}; + int count = 0; + + while(mstream_can_read(s)) { +@@ -1571,8 +1572,10 @@ static int read_prefix_list(struct mstream *s, u_int16_t afi, struct prefix *pre + if (is_addp) + path_id = mstream_getl(s, NULL); + +- u_int8_t p_len = mstream_getc(s,NULL); // length in bits +- u_int8_t p_bytes = (p_len + 7) / 8; ++ u_int8_t p_len = mstream_getc(s,NULL); // prefix length in bits ++ u_int8_t p_bytes = p_len / 8; // number of complete octets to read ++ u_int8_t p_mask = p_len % 8; // number of remaining significant bits ++ if (p_mask) p_bytes++; // if remaining bits, need to read one more octet + + /* Truncated prefix list? */ + if(mstream_can_read(s) < p_bytes) { +@@ -1596,7 +1599,26 @@ static int read_prefix_list(struct mstream *s, u_int16_t afi, struct prefix *pre + continue; + + *prefix = (struct prefix) { .len = p_len, .path_id = path_id }; ++ ++ /* ++ RFC4271: ++ The Prefix field contains an IP address prefix, followed by ++ the minimum number of trailing bits needed to make the end ++ of the field fall on an octet boundary. Note that the value ++ of trailing bits is irrelevant. ++ ++ Some implementations (including bgpdump.c) pass the address directly ++ into inet_ntoa() without first considering the prefix length. ++ This isn't a problem for anything that works with prefix lengths. ++ But the resulting address visual representation can look wrong. ++ To avoid any confusion, we mask the trailing bits to 0 also. ++ */ ++ + mstream_get(s, &prefix->address, p_bytes); ++ ++ /* Mask trailing bits to 0 if not aligned on a octet boundary */ ++ if (p_mask) ++ ((u_int8_t *)&prefix->address)[p_bytes - 1] &= maskarray[p_mask - 1]; + } + + if(count > MAX_PREFIXES) { @@ -2,28 +2,46 @@ pkgname=bgpdump pkgver=1.6.2 -pkgrel=1 +pkgrel=2 pkgdesc='Utility and C Library for parsing MRT files' arch=('x86_64') url="https://github.com/RIPE-NCC/bgpdump" license=('GPL2') depends=('zlib' 'bzip2') makedepends=() -source=("https://github.com/RIPE-NCC/bgpdump/archive/v${pkgver}.tar.gz") -sha256sums=('415692c173a84c48b1e927a6423a4f8fd3e6359bc3008c06b7702fe143a76223') +source=("https://github.com/RIPE-NCC/bgpdump/archive/v${pkgver}.tar.gz" + '05-addr-representation.diff' + 'updates.nlri_mask_trailing_bits.gz' + 'updates.nlri_mask_trailing_bits.gz.bgp.gz') +sha256sums=('415692c173a84c48b1e927a6423a4f8fd3e6359bc3008c06b7702fe143a76223' + '86efd03c29add6e93596b3df8eb8a6eded67a907811e2ff61f60c8bb4ac663df' + '19ed2d93b3dd30cbb5af3bdccf421e22b685e9944138b96a72b34660865a5607' + '8f71ea4caa5d22cf9e105a64be1be91a3168fd4ee6113ec2ff863cefc526b506') + +prepare() { + cd "$srcdir/$pkgname-$pkgver" + patch -Np1 -i "$srcdir/05-addr-representation.diff" + cp "$srcdir/updates.nlri_mask_trailing_bits.gz" test_data/ + cp "$srcdir/updates.nlri_mask_trailing_bits.gz.bgp.gz" test_expect/ +} build() { - cd "${srcdir}/${pkgname}-${pkgver}" + cd "$srcdir/$pkgname-$pkgver" autoheader autoconf ./configure --prefix=/usr --sbindir=/usr/bin make } +check() { + cd "$srcdir/$pkgname-$pkgver" + make check +} + package() { - cd "${srcdir}/${pkgname}-${pkgver}" - make DESTDIR="${pkgdir}" install - install -Dm 644 COPYING "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE" + cd "$srcdir/$pkgname-$pkgver" + make DESTDIR="$pkgdir" install + install -Dm 644 COPYING "$pkgdir/usr/share/licenses/$pkgname/LICENSE" } # vim: set ts=4 sw=4 et : diff --git a/updates.nlri_mask_trailing_bits.gz b/updates.nlri_mask_trailing_bits.gz Binary files differnew file mode 100644 index 000000000000..d39d49e51f3a --- /dev/null +++ b/updates.nlri_mask_trailing_bits.gz diff --git a/updates.nlri_mask_trailing_bits.gz.bgp.gz b/updates.nlri_mask_trailing_bits.gz.bgp.gz Binary files differnew file mode 100644 index 000000000000..40bea2038ee4 --- /dev/null +++ b/updates.nlri_mask_trailing_bits.gz.bgp.gz |