38 Commits
1.10 ... main

Author SHA1 Message Date
Denis Fondras
20673db180 Remove extraneous space in Arista prefixlist (#124)
Some checks failed
Build and test (latest Ubuntu/macOS) / build (ubuntu-latest) (push) Successful in 30s
Build and test (latest Ubuntu/macOS) / build (macos-latest) (push) Has been cancelled
basic unit tests / output unit tests (push) Has been cancelled
CodeQL analysis / Analyze (cpp) (push) Failing after 2m11s
* Remove extraneous space in Arista prefixlist

When diffing config generated with bgpq4 with config exported from an Arista device, many lines are returned as changed. This is because prefixlist on Arista device use 3 spaces and bgpq4 uses 4 spaces.

* Update eos--4.txt

* Update eos--6.txt
2025-02-21 20:55:15 +01:00
Job Snijders
4cae7d1df5 test if symlink
Some checks failed
Build and test (latest Ubuntu/macOS) / build (ubuntu-latest) (push) Successful in 28s
Build and test (latest Ubuntu/macOS) / build (macos-latest) (push) Has been cancelled
basic unit tests / output unit tests (push) Has been cancelled
CodeQL analysis / Analyze (cpp) (push) Failing after 1m12s
2025-02-08 13:25:31 +00:00
Job Snijders
851d1c6cf1 force cp when not symlink 2025-02-08 13:23:01 +00:00
Job Snijders
f53fbba8b3 only add awk in fedora42
Some checks failed
Build and test (latest Ubuntu/macOS) / build (macos-latest) (push) Waiting to run
basic unit tests / output unit tests (push) Waiting to run
Build and test (latest Ubuntu/macOS) / build (ubuntu-latest) (push) Successful in 27s
CodeQL analysis / Analyze (cpp) (push) Failing after 28s
Build and test (linux matrix) / build (alpine:3.21) (push) Failing after 5s
Build and test (linux matrix) / build (alpine:edge) (push) Failing after 5s
Build and test (linux matrix) / build (centos/centos:stream10) (push) Failing after 5s
Build and test (linux matrix) / build (centos/centos:stream9) (push) Failing after 5s
Build and test (linux matrix) / build (debian:bookworm) (push) Failing after 5s
Build and test (linux matrix) / build (debian:bullseye) (push) Failing after 5s
Build and test (linux matrix) / build (debian:trixie) (push) Failing after 4s
Build and test (linux matrix) / build (fedora/fedora:40) (push) Failing after 4s
Build and test (linux matrix) / build (fedora/fedora:41) (push) Failing after 4s
Build and test (linux matrix) / build (fedora/fedora:42) (push) Failing after 4s
Build and test (linux matrix) / build (rockylinux/rockylinux:8) (push) Failing after 4s
Build and test (linux matrix) / build (rockylinux/rockylinux:9) (push) Failing after 5s
Build and test (linux matrix) / build (ubuntu:focal) (push) Failing after 5s
Build and test (linux matrix) / build (ubuntu:jammy) (push) Failing after 5s
Build and test (linux matrix) / build (ubuntu:noble) (push) Failing after 5s
2025-02-07 15:41:31 +00:00
Job Snijders
282378e673 add awk to fedora42 image
Some checks failed
Build and test (latest Ubuntu/macOS) / build (macos-latest) (push) Waiting to run
basic unit tests / output unit tests (push) Waiting to run
Build and test (latest Ubuntu/macOS) / build (ubuntu-latest) (push) Successful in 28s
CodeQL analysis / Analyze (cpp) (push) Failing after 1m9s
Build and test (linux matrix) / build (alpine:3.21) (push) Failing after 5s
Build and test (linux matrix) / build (alpine:edge) (push) Failing after 5s
Build and test (linux matrix) / build (centos/centos:stream10) (push) Failing after 4s
Build and test (linux matrix) / build (centos/centos:stream9) (push) Failing after 4s
Build and test (linux matrix) / build (debian:bookworm) (push) Failing after 5s
Build and test (linux matrix) / build (debian:bullseye) (push) Failing after 5s
Build and test (linux matrix) / build (debian:trixie) (push) Failing after 5s
Build and test (linux matrix) / build (fedora/fedora:40) (push) Failing after 5s
Build and test (linux matrix) / build (fedora/fedora:41) (push) Failing after 5s
Build and test (linux matrix) / build (fedora/fedora:42) (push) Failing after 4s
Build and test (linux matrix) / build (rockylinux/rockylinux:8) (push) Failing after 4s
Build and test (linux matrix) / build (rockylinux/rockylinux:9) (push) Failing after 5s
Build and test (linux matrix) / build (ubuntu:focal) (push) Failing after 5s
Build and test (linux matrix) / build (ubuntu:jammy) (push) Failing after 5s
Build and test (linux matrix) / build (ubuntu:noble) (push) Failing after 5s
2025-02-07 15:28:14 +00:00
Denis Fondras
60a3b3dabf Forbid -e -E -6 (#123)
The resulting list is a bit weird 😉 

```
 permit ip host 2a05:6340:: host 255.255.255.248
 permit ip host 2a06:19c0:: host 255.255.255.248
 permit ip host 2a07:4b00:: host 255.255.255.248
 permit ip host 2a07:7b40:: host 255.255.255.248
```
2025-02-07 10:08:06 -05:00
Robert Scheck
b769ad9ce6 Update workflow actions and containers (#121) 2024-12-26 02:21:19 +01:00
Robert Scheck
0678439386 Update matrixbuild to current Linux distributions (#120) 2024-12-25 12:21:17 +01:00
Yureka
c51fddefe5 filter out ASN 0 in juniper as-lists (#117)
Fixes error "RPD Policy: Invalid AS 0"
2024-10-16 16:01:36 +00:00
Job Snijders
ad20b71f70 add symlinks, thanks rsc 2024-08-25 13:02:15 +00:00
Job Snijders
983c4f74c2 maybe this one? 2024-08-25 11:19:29 +00:00
Job Snijders
8ed8ae112f Update build targets 2024-08-25 11:07:59 +00:00
Tim de Boer
44e97736ac Remove extra space for MikroTik's RouterOS V7 rules (#115) 2024-08-25 11:01:51 +00:00
Job Snijders
7bd337eac3 Respin release 2024-05-15 11:25:17 +00:00
Job Snijders
4dd3b92b3c Release 1.14 2024-05-15 11:24:02 +00:00
Job Snijders
a97f7eb4ff Update changelog 2024-05-13 12:19:19 +00:00
Robert Scheck
4ab84255a4 Work around broken Docker image by Rocky Linux (until CentOS 7 is EOL) (#114) 2024-05-10 12:16:04 +02:00
Job Snijders
424770be0b Set TCP_NODELAY on the socket
Nagle's algorithm probably serves no purpose with whois queries
often being tiny.
2024-05-10 09:41:28 +00:00
Robert Scheck
4bac9e7e53 Skip online test if no or empty /etc/resolv.conf (#113)
Downstream build systems, e.g. at Linux distributions like Fedora,
might be (sealed) offline (chroot) environments.
2024-05-05 22:33:12 +00:00
Robert Scheck
2ec0ea3fbd Don't try to login and push to GHCR on forks (#112) 2024-05-03 23:55:16 +02:00
Job Snijders
0a83c7598d Fix comma display in ingress IOS XR as-path-set printing 2024-05-01 12:26:30 +00:00
Job Snijders
f44bf47b1f Don't try to maximize the send buffer
Get rid of code that did a binary search to maximize the send buffer
via setsockopt SO_SNDBUF. It caused problems for modern Mac users.
2024-05-01 12:00:17 +00:00
Job Snijders
9ffc4f8ec6 Add missing newline 2024-05-01 12:00:09 +00:00
Job Snijders
a89ac75590 experiment 1 2024-05-01 11:45:59 +00:00
Job Snijders
59f800f31f Do not fiddle with the socket buffer size 2024-05-01 11:20:41 +00:00
Job Snijders
6c8bb871c0 fix path 2024-05-01 11:08:19 +00:00
Job Snijders
26b0827813 Add simple check target 2024-05-01 11:03:05 +00:00
Job Snijders
36a54c9b41 reference correct CI badge 2024-04-30 23:49:23 +00:00
Job Snijders
e743be94b3 add build imagery 2024-04-30 23:46:41 +00:00
Robert Scheck
b631d43755 Modernize usage of autoconf macros (#110) 2024-04-30 23:42:39 +00:00
Robert Scheck
57a70da5a9 Bump GitHub action versions in workflows (#106) 2024-04-30 23:41:45 +00:00
Job Snijders
95d3a4c12b Release 1.12 2024-02-12 16:57:03 +00:00
Robert Scheck
2e06d3c389 Update matrixbuild to current Linux distributions (#99) 2023-12-10 05:08:50 +01:00
Darshan Kowlaser
3d2eed555d fixed - mikrotik routerosv7 output (#103)
* fixed - mikrotik routerosv7 output

* fixed - mikrotik routerosv7 output

---------

Co-authored-by: dkayza-xxx <darshan@darshankowlaser.com>
2023-11-27 19:17:36 +01:00
Job Snijders
a28752247c update changelog 2023-06-20 12:24:28 +00:00
Job Snijders
26d631b257 By default disallow 23456 as origin
Can be bypassed with '-p'
2023-06-20 12:18:41 +00:00
Job Snijders
841840be68 whoops, forgot to bump version 2023-06-17 05:33:11 +00:00
J vanBemmel
8ae08b79b1 Update README.md - document -n2 option (#95) 2023-06-04 00:56:09 +02:00
30 changed files with 134 additions and 184 deletions

View File

@@ -2,8 +2,8 @@ ARG image=centos/centos:latest
FROM quay.io/$image
# Install dependencies
RUN yum update -y
RUN yum install -y autoconf automake gcc libtool make diffutils file gzip
RUN dnf -y update
RUN dnf -y install autoconf automake gcc libtool make diffutils file gzip
# Add source code
ADD . /src

View File

@@ -1 +0,0 @@
../centos.Dockerfile

View File

@@ -1 +0,0 @@
../centos.Dockerfile

View File

@@ -0,0 +1,17 @@
ARG image=centos/centos:latest
FROM quay.io/$image
# Install dependencies
RUN dnf -y update
RUN dnf -y install autoconf automake gcc libtool make diffutils file gzip awk
# Add source code
ADD . /src
WORKDIR /src
# Run steps
RUN ./bootstrap
RUN ./configure
RUN make
RUN make check
RUN make distcheck

View File

@@ -19,24 +19,24 @@ jobs:
build:
name: Build container
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
needs: test
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- # Add support for more platforms with QEMU
# https://github.com/docker/setup-qemu-action
name: Set up QEMU
uses: docker/setup-qemu-action@v2
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository_owner }}/bgpq4
tags: |
@@ -48,17 +48,18 @@ jobs:
type=sha
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
if: github.repository_owner == 'bgp'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v4
uses: docker/build-push-action@v6
with:
file: .github/images/alpine:3.Dockerfile
context: .
platforms: linux/amd64,linux/arm64
push: true
push: ${{ github.repository_owner == 'bgp' }}
tags: ${{ steps.meta.outputs.tags }}

View File

@@ -9,7 +9,7 @@ jobs:
matrix:
os: [ubuntu-latest, macos-latest]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: install macOS autogen prerequisites
run: brew install autoconf automake libtool
if: runner.os == 'macOS'

View File

@@ -22,9 +22,9 @@ jobs:
language: [ 'cpp' ]
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
- name: Build Application using script
@@ -33,6 +33,6 @@ jobs:
./configure
make
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"

View File

@@ -9,23 +9,25 @@ jobs:
fail-fast: false
matrix:
dockerenv:
- debian:trixie
- debian:bookworm
- debian:bullseye
- debian:buster
- ubuntu:noble
- ubuntu:jammy
- ubuntu:focal
- ubuntu:bionic
- fedora/fedora:38
- fedora/fedora:37
- fedora/fedora:36
- fedora/fedora:42
- fedora/fedora:41
- fedora/fedora:40
- centos/centos:stream10
- centos/centos:stream9
- centos/centos:stream8
- centos/centos:7
- rockylinux/rockylinux:9
- rockylinux/rockylinux:8
- alpine:edge
- alpine:3.17
- alpine:3.21
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Work around Docker BuildKit regression
# https://github.com/moby/buildkit/issues/2119: `DOCKER_BUILDKIT=1 docker build` fails if Dockerfile is a symlink
run: [ -L .github/images/${{matrix.dockerenv}}.Dockerfile ] && cp --remove-destination $(readlink -f .github/images/${{matrix.dockerenv}}.Dockerfile) .github/images/${{matrix.dockerenv}}.Dockerfile
- name: Run build on ${{matrix.dockerenv}}
run: docker build . --file .github/images/${{matrix.dockerenv}}.Dockerfile --build-arg image=${{matrix.dockerenv}}

View File

@@ -8,15 +8,18 @@ on:
- reopened
- ready_for_review
- synchronize
push:
branches:
- main
workflow_call:
jobs:
output-unit-tests:
name: output unit tests
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- name: clone repo
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: install pre-reqs
run: |
sudo apt-get update

20
CHANGES
View File

@@ -1,3 +1,23 @@
1.15 (2024-05-15)
- Apologies, debug code slipped into the last release
1.14 (2024-05-14)
- Small performance gain: set TCP_NODELAY on the socket
1.13 (2024-05-01)
- Fixed a bug for Mac users by removing sx_maxsockbuf()
- Fixed a comma printing bug in IOS XR as-path-set output
1.12 (2024-02-12)
- Fix a bug in the mikrotik printer
1.11 (2023-06-20)
- disallow AS 23456 as origin (can be bypassed via -p)
1.10 (2023-06-03)
- Add support for Nokia SR Linux IP prefix lists / ACL filters
- Accept -3 as a no-op for bgpq3 compatibility
1.9 (2023-03-05)
- Bugfix for -S problem (bgpq4#83) by James Bensley

View File

@@ -17,7 +17,6 @@ bgpq4_LDADD += $(top_builddir)/compat/libcompat.la
endif
bgpq4_SOURCES=main.c extern.h printer.c expander.c \
sx_maxsockbuf.c \
sx_prefix.c sx_prefix.h \
sx_report.c sx_report.h \
sx_slentry.c
@@ -33,3 +32,12 @@ MAINTAINERCLEANFILES=configure aclocal.m4 compile \
maintainer-clean-local:
-rm -rf m4 autom4te.cache
check:
./bgpq4 -v
@echo
-if [ -s /etc/resolv.conf ]; then \
./bgpq4 -ddd -6 AS15562:AS-SNIJDERS ; \
else \
echo "No or empty /etc/resolv.conf, skipping online test"; \
fi

View File

@@ -1,3 +1,9 @@
[![CI](https://github.com/bgp/bgpq4/actions/workflows/unit-tests.yml/badge.svg)](https://github.com/bgp/bgpq4/actions/workflows/unit-tests.yml)
<a href="https://repology.org/project/bgpq4/versions">
<img src="https://repology.org/badge/vertical-allrepos/bgpq4.svg" alt="Packaging status" align="right">
</a>
# NAME
**bgpq4** - bgp filtering automation tool
@@ -128,6 +134,10 @@ It's options are as follows:
> generate config for Nokia SR OS MD-CLI (Cisco IOS by default)
**-n2**
> generate config for Nokia SR Linux (Cisco IOS by default)
**-N**
> generate config for Nokia SR OS classic CLI (Cisco IOS by default).

View File

@@ -1 +1 @@
1.9
1.15

View File

@@ -114,7 +114,8 @@ generate config for Nokia SR Linux (Cisco IOS by default)
.It Fl N
generate config for Nokia SR OS classic CLI (Cisco IOS by default).
.It Fl p
emit prefixes where the origin ASN is in the private ASN range (disabled by default).
emit prefixes where the origin ASN is 23456 or in the private ASN range
(disabled by default).
.It Fl r Ar len
allow more specific routes starting with specified masklen too.
.It Fl R Ar len

View File

@@ -13,7 +13,7 @@
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
AC_INIT([bgpq4], m4_esyscmd([tr -d '\n' < VERSION]), job@sobornost.net)
AC_INIT([bgpq4], m4_esyscmd([tr -d '\n' < VERSION]), [job@sobornost.net])
AC_CANONICAL_HOST
AM_INIT_AUTOMAKE([subdir-objects foreign])
@@ -56,9 +56,8 @@ AM_CONDITIONAL([HOST_NETBSD], [test x$HOST_OS = xnetbsd])
AM_CONDITIONAL([HOST_SOLARIS], [test x$HOST_OS = xsolaris])
AC_PROG_CC
AC_PROG_CC_STDC
AM_PROG_CC_C_O
AC_PROG_LIBTOOL
LT_INIT
AC_PROG_INSTALL
AC_ARG_ENABLE(warnings,

View File

@@ -29,6 +29,7 @@
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/select.h>
#include <netinet/tcp.h>
#include <assert.h>
#include <ctype.h>
@@ -183,7 +184,7 @@ int
bgpq_expander_add_as(struct bgpq_expander *b, char *as)
{
char *eoa;
uint32_t asno = 0;
uint32_t asno = 0;
struct asn_entry *asne;
if (!b || !as)
@@ -191,14 +192,14 @@ bgpq_expander_add_as(struct bgpq_expander *b, char *as)
asno = strtoul(as + 2, &eoa, 10);
if (eoa && *eoa != 0) {
sx_report(SX_ERROR,"Invalid symbol in AS number: '%c' in %s\n",
sx_report(SX_ERROR, "Invalid symbol in AS number: '%c' in %s\n",
*eoa, as);
return 0;
}
if (!expand_special_asn &&
(asno >= 4200000000ul || (asno >= 64496 && asno <= 65551))) {
sx_report(SX_ERROR,"Invalid AS number: %u\n", asno);
if (!expand_special_asn && (asno == 23456 || asno >= 4200000000ul
|| (asno >= 64496 && asno <= 65551))) {
sx_report(SX_ERROR, "Invalid AS number: %u\n", asno);
return 0;
}
@@ -1034,7 +1035,7 @@ bgpq_expand(struct bgpq_expander *b)
struct addrinfo hints, *res = NULL, *rp;
struct linger sl;
struct asn_entry *asne;
int fd = -1, err, ret, aquery = 0;
int fd = -1, err, ret, aquery = 0, nodelay = 1;
int slen;
sl.l_onoff = 1;
@@ -1074,15 +1075,12 @@ bgpq_expand(struct bgpq_expander *b)
fd = -1;
continue;
}
err = sx_maxsockbuf(fd, SO_SNDBUF);
if (err > 0) {
SX_DEBUG(debug_expander, "Acquired sendbuf of %i "
"bytes\n", err);
} else {
close(fd);
fd = -1;
continue;
}
if (setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &nodelay,
sizeof(nodelay)) == -1)
SX_DEBUG(debug_expander, "Unable to set TCP_NODELAY on"
" socket: %s\n", strerror(errno));
break;
}

View File

@@ -149,9 +149,6 @@ void sx_radix_tree_freeall(struct sx_radix_tree *t);
void bgpq_prequest_freeall(struct bgpq_prequest *bpr);
void expander_freeall(struct bgpq_expander *expander);
/* s - number of opened socket, dir is either SO_SNDBUF or SO_RCVBUF */
int sx_maxsockbuf(int s, int dir);
#ifndef HAVE_STRLCPY
size_t strlcpy(char *dst, const char *src, size_t size);
#endif

9
main.c
View File

@@ -94,6 +94,7 @@ usage(int ecode)
printf(" -M match : extra match conditions for JunOS route-filters\n");
printf(" -l name : use specified name for generated access/prefix/.."
" list\n");
printf(" -p : allow special ASNs like 23456 or in the private range\n");
printf(" -R len : allow more specific routes up to specified masklen\n");
printf(" -r len : allow more specific routes from masklen specified\n");
printf(" -s : generate sequence numbers in prefix-lists (IOS only)\n");
@@ -603,6 +604,14 @@ main(int argc, char* argv[])
exit(1);
}
if (expander.vendor == V_ARISTA
&& expander.generation == T_EACL
&& expander.family == AF_INET6) {
sx_report(SX_FATAL, "Sorry, extended access-lists is not compatible "
"with Arista EOS and IPv6\n");
exit(1);
}
if (expander.sequence
&& (expander.vendor != V_CISCO && expander.vendor != V_ARISTA)) {
sx_report(SX_FATAL, "Sorry, prefix-lists sequencing (-s) supported"

View File

@@ -89,7 +89,7 @@ bgpq4_print_cisco_aspath(FILE *f, struct bgpq_expander *b)
static void
bgpq4_print_cisco_xr_aspath(FILE *f, struct bgpq_expander *b)
{
int nc = 0, comma = 1;
int nc = 0, comma = 0;
struct asn_entry *asne, find, *res;
fprintf(f, "as-path-set %s", b->name);
@@ -98,6 +98,7 @@ bgpq4_print_cisco_xr_aspath(FILE *f, struct bgpq_expander *b)
if ((res = RB_FIND(asn_tree, &b->asnlist, &find)) != NULL) {
fprintf(f, "\n ios-regex '^%u(_%u)*$'", res->asn, res->asn);
RB_REMOVE(asn_tree, &b->asnlist, res);
comma = 1;
}
RB_FOREACH(asne, asn_tree, &b->asnlist) {
@@ -299,12 +300,15 @@ bgpq4_print_juniper_aslist(FILE *f, struct bgpq_expander *b)
RB_FOREACH(asne, asn_tree, &b->asnlist) {
if (!nc) {
fprintf(f, " as-list a%u members [ %u",
lineNo, asne->asn);
} else {
fprintf(f," %u", asne->asn);
fprintf(f, " as-list a%u members [",
lineNo);
}
// Filter out AS 0
// "error: RPD Policy: Invalid AS 0"
if (asne->asn != 0)
fprintf(f," %u", asne->asn);
nc++;
if (nc == b->aswidth) {
@@ -1161,7 +1165,7 @@ bgpq4_print_eprefix(struct sx_radix_node *n, void *ff)
sx_prefix_snprintf(n->prefix, prefix, sizeof(prefix));
snprintf(seqno, sizeof(seqno), " seq %i", seq++);
snprintf(seqno, sizeof(seqno), "seq %i", seq++);
if (n->isAggregate) {
if (n->aggregateLow > n->prefix->masklen) {
@@ -1864,13 +1868,13 @@ bgpq4_print_k7prefix(struct sx_radix_node *n, void *ff)
if (n->isAggregate)
fprintf(f,"/routing filter rule add chain=\""
"%s-%s\" rule=\"if (dst in %s && dst-len in %d-%d) {accept}\"\n",
"%s-%s\" rule=\"if (dst in %s && dst-len in %d-%d) {accept}\"\n",
bname ? bname : "NN",
n->prefix->family == AF_INET ? "V4" : "V6",
prefix, n->aggregateLow, n->aggregateHi);
else
fprintf(f,"/routing filter rule add chain=\""
"%s-%s\" rule=\"if (dst=%s) {accept}\"\n",
"%s-%s\" rule=\"if (dst==%s) {accept}\"\n",
bname ? bname : "NN",
n->prefix->family == AF_INET ? "V4" : "V6",
prefix);

View File

@@ -1,117 +0,0 @@
/*
* Copyright (c) 2019-2020 Job Snijders <job@sobornost.net>
* Copyright (c) 2007-2019 Alexandre Snarskii <snar@snar.spb.ru>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "extern.h"
#include "sx_report.h"
int
sx_maxsockbuf(int s, int dir)
{
int optval = 0, voptval;
int hiconf = -1, loconf = -1;
unsigned int voptlen;
int phase = 0, iterations = 0;
if (s < 0) {
sx_report(SX_FATAL,"Unable to maximize sockbuf on invalid "
"socket %i\n", s);
exit(1);
}
voptlen = sizeof(optval);
if (getsockopt(s, SOL_SOCKET, dir, (void*)&optval, &voptlen) == -1) {
sx_report(SX_ERROR,"initial getsockopt failed: %s\n",
strerror(errno));
return -1;
}
for (;;) {
iterations++;
if (phase == 0)
optval <<= 1;
else {
if (optval == (hiconf + loconf) / 2)
break;
optval = (hiconf + loconf) / 2;
}
if (setsockopt(s, SOL_SOCKET, dir, (void*)&optval,
sizeof(optval)) == -1) {
if (phase == 0)
phase = 1;
hiconf = optval;
continue;
} else {
loconf = optval;
}
voptlen = sizeof(voptval);
if (getsockopt(s, SOL_SOCKET, dir, (void*)&voptval,
&voptlen) == -1) {
sx_report(SX_ERROR,"getsockopt failed: %s\n",
strerror(errno));
return -1;
} else if (voptval < optval) {
if (phase == 0) {
phase = 1;
optval >>= 1;
continue;
} else if (phase == 1) {
phase = 2;
optval -= 2048;
continue;
} else
break;
}
}
voptlen = sizeof(voptval);
if (getsockopt(s, SOL_SOCKET, dir, (void*)&voptval,
&voptlen) == -1) {
sx_report(SX_ERROR,"getsockopt(final stage) failed: %s\n",
strerror(errno));
return -1;
} else
return voptval;
}

View File

@@ -1,4 +1,4 @@
no ip prefix-list NN
ip prefix-list NN
seq 1 permit 192.31.196.0/24
seq 2 permit 192.175.48.0/24
seq 1 permit 192.31.196.0/24
seq 2 permit 192.175.48.0/24

View File

@@ -1,4 +1,4 @@
no ipv6 prefix-list NN
ipv6 prefix-list NN
seq 1 permit 2001:4:112::/48
seq 2 permit 2620:4f:8000::/48
seq 1 permit 2001:4:112::/48
seq 2 permit 2620:4f:8000::/48

View File

@@ -1,2 +1,2 @@
/routing filter rule add chain="NN-V4" rule="if (dst=192.31.196.0/24) {accept}"
/routing filter rule add chain="NN-V4" rule="if (dst=192.175.48.0/24) {accept}"
/routing filter rule add chain="NN-V4" rule="if (dst==192.31.196.0/24) {accept}"
/routing filter rule add chain="NN-V4" rule="if (dst==192.175.48.0/24) {accept}"

View File

@@ -1,2 +1,2 @@
/routing filter rule add chain="NN-V6" rule="if (dst=2001:4:112::/48) {accept}"
/routing filter rule add chain="NN-V6" rule="if (dst=2620:4f:8000::/48) {accept}"
/routing filter rule add chain="NN-V6" rule="if (dst==2001:4:112::/48) {accept}"
/routing filter rule add chain="NN-V6" rule="if (dst==2620:4f:8000::/48) {accept}"