Re: more generic cpu freq reporting

2022-04-25 Thread Claudio Jeker
On Mon, Apr 25, 2022 at 05:22:51PM +0200, Hrvoje Popovski wrote: > On 25.4.2022. 16:50, Hrvoje Popovski wrote: > > On 25.4.2022. 16:19, Claudio Jeker wrote: > >> After I sent out my ksmn(4) diff to include cpu frequency sensors dlg@ > >> told me that this is a generic wa

Re: beef up ksmn(4) to show more temps and CPU frequency

2022-04-25 Thread Claudio Jeker
On Mon, Apr 25, 2022 at 11:31:22AM -0400, Bryan Steele wrote: > On Mon, Apr 25, 2022 at 05:20:46PM +0200, Claudio Jeker wrote: > > On Sun, Apr 24, 2022 at 07:06:19PM +0200, Claudio Jeker wrote: > > > On Ryzen CPUs each CCD has a temp sensor. If the CPU has CCDs (which > >

Re: beef up ksmn(4) to show more temps and CPU frequency

2022-04-25 Thread Claudio Jeker
On Sun, Apr 24, 2022 at 07:06:19PM +0200, Claudio Jeker wrote: > On Ryzen CPUs each CCD has a temp sensor. If the CPU has CCDs (which > excludes Zen APU CPUs) this should show additional temp info. This is > based on info from the Linux k10temp driver. > > Additionally use t

more generic cpu freq reporting

2022-04-25 Thread Claudio Jeker
After I sent out my ksmn(4) diff to include cpu frequency sensors dlg@ told me that this is a generic way to find the cpu frequency on modern x86 cpus (both intel and amd support it). So this diff cleans up the CPU frequency sensors and moves them to the cpu(4). I had to split the sensor

cleanup multicast rttimer queues

2022-04-27 Thread Claudio Jeker
There is no need to have a rttimer queue per rdomain. The rttimer itself is rdomain aware and so this just make everything more complicated for no gain. This diff just drops back to a single queue and initializes the queues in ip_init() and the IPv6 counterpart. I have no mrouter setup to test

Use vgonel() in vop_generic_revoke

2022-04-27 Thread Claudio Jeker
This is just a mini cleanup. Switch from vgone() to vgonel() like it is done a bit later already. vgone() is just a wrapper around vgonel() using curproc (which is cached in vop_generic_revoke()). -- :wq Claudio Index: vfs_default.c

Re: use cpu sensor for cpuspeed

2022-05-15 Thread Claudio Jeker
On Sun, May 15, 2022 at 10:35:43AM +0200, Mark Kettenis wrote: > > From: "Ted Unangst" > > Date: Sat, 14 May 2022 20:23:39 -0400 > > > > The cpu hz sensor is more accurate and updates faster than than the value > > currently used for hw.cpuspeed. So return that value (scaled). > > > > This

tcpudmp: no more AS_DOT encoding in bgp output

2022-05-25 Thread Claudio Jeker
Long long ago it was considered chique to use AS_DOT to write 4-byte AS numbers. Like 3.10 instead of 196618. tcpdump also followed this trend but then the world switched to AS_PLAIN so did bgpd. It is time for tcpdump to follow. Now the ugly bit about the ASPATH attribute is that it is not

Re: bgpd fix for non-transitive extended communities

2022-05-25 Thread Claudio Jeker
On Wed, May 25, 2022 at 03:50:38PM +0200, Theo Buehler wrote: > On Wed, May 25, 2022 at 02:46:55PM +0200, Claudio Jeker wrote: > > Noticed this morning working on something else. The non-transitive > > extended community support is fairly messed up. In my case (set > >

Re: rpki-client: implement rsc-08.txt with templates

2022-05-31 Thread Claudio Jeker
On Tue, May 31, 2022 at 01:16:19PM +0200, Theo Buehler wrote: > I chose to implement the constrained versions of the RFC 3779 types from > the draft because the OpenSSL RFC 3779 code has static IPAddrBlocks_it, > so we have to work around that anyway. This isn't quite minimal, but it > avoids

bgpd implement max-communities filter

2022-05-25 Thread Claudio Jeker
This introduces max-communities, max-ext-communities and max-large-communities for filters which allows to limit the number of communities in a path. The 3 filters can all be used together and also with other match filters including community X:Y. -- :wq Claudio Index: bgpd.conf.5

Re: bgpd cleanup RTP_ limit checks in parse.y

2022-06-02 Thread Claudio Jeker
On Thu, Jun 02, 2022 at 12:44:49PM +0200, Theo Buehler wrote: > On Thu, Jun 02, 2022 at 11:38:05AM +0200, Claudio Jeker wrote: > > Lets use the same check for both priority checks in parse.y. > > Also rephrase the error messages to be less cryptic. > > Both checks do the same

Re: rpki-client: limit number of RSC checklist entries?

2022-06-01 Thread Claudio Jeker
On Wed, Jun 01, 2022 at 08:44:43AM +0200, Theo Buehler wrote: > When compared to manifest FileAndHash, the RSC code doesn't limit the > size of the FileNameAndHash list. Should we do this for consistency? > > The situation is of course not quite the same since we're in -f mode. > However, we do

bgpd cleanup RTP_ limit checks in parse.y

2022-06-02 Thread Claudio Jeker
Lets use the same check for both priority checks in parse.y. Also rephrase the error messages to be less cryptic. Both checks do the same check since RTP_NONE = 0 and RTP_LOCAL = 1. Using RTP_LOCAL as a priority is actually not possible since that one is reserved for the kernel (used by interface

Re: bgpd, check ktable_exists return value

2022-06-02 Thread Claudio Jeker
On Thu, Jun 02, 2022 at 11:13:31AM +0200, Theo Buehler wrote: > On Thu, Jun 02, 2022 at 11:05:26AM +0200, Claudio Jeker wrote: > > When setting the default routing table for bgpd make sure that > > ktable_exists() does not fail. > > Also improve the warning message in

bgpd, check ktable_exists return value

2022-06-02 Thread Claudio Jeker
When setting the default routing table for bgpd make sure that ktable_exists() does not fail. Also improve the warning message in ktable_exists() a bit. -- :wq Claudio Index: kroute.c === RCS file: /cvs/src/usr.sbin/bgpd/kroute.c,v

use timeout for rttimer

2022-05-13 Thread Claudio Jeker
This diff replaces most of the rttimer with a timeout(9) call. Instead of running a 1 second timer all the time it runs idividual timeouts for each rttimer object. rt_timer_remove_all() needs to be careful to not remove the rttimer object while the timeout callback is running or up to be run. It

Re: rpki-client: clean up ip handling in cert.c

2022-05-12 Thread Claudio Jeker
On Thu, May 12, 2022 at 10:17:30AM +0200, Theo Buehler wrote: > Before refactoring the IP side, let's streamline the code a little. > Populate struct ip in the leaf functions instead of handing it through > several layers and copying it along the way. Pass in the afi instead of > letting struct ip

Re: rpki-client: fewer reallocarrays() for IPAddrBlocks

2022-05-12 Thread Claudio Jeker
On Thu, May 12, 2022 at 11:27:21AM +0200, Theo Buehler wrote: > This aligns sbgp_ipaddrblk() with sbgp_assysnum(), giving it a similar > treatment. We trade the reallocarray() per prefix or range with at most > two recallocarray(). I took the liberty of trimming some RFC section > numbers in

rpki-client unify max request defines

2022-05-24 Thread Claudio Jeker
This diff moves and renames the defines that define the maximum number of parallel requests for http and rsync. The defines are now MAX_HTTP_REQUESTS and MAX_RSYNC_REQUESTS the values remane the same. Also move the memset of pollfd sets in http.c into the loop. It is not needed but I prefer it

bgpd fix for non-transitive extended communities

2022-05-25 Thread Claudio Jeker
Noticed this morning working on something else. The non-transitive extended community support is fairly messed up. In my case (set ext-community rt 1:1) it causes the community to be skipped. First of all the check in non_transitive_community() is messed up. It uses the wrong data field, does a

Re: tcpdump: add RFC9234 "BGP Role" support

2022-05-25 Thread Claudio Jeker
On Tue, May 24, 2022 at 08:12:25PM +, Job Snijders wrote: > Hi all, > > I based this off reading https://datatracker.ietf.org/doc/html/rfc9234 > > This code is untested! I haven't had a chance yet to tcpdump a RFC 9234 > capable BGP speaker. There might be some out there, according to >

Re: rpki-client: ASN.1 bit string flag errors

2022-05-12 Thread Claudio Jeker
On Thu, May 12, 2022 at 07:44:51PM +0200, Theo Buehler wrote: > ip_addr_parse() sticks its fingers into undocumented API surface of > libcrypto. What is true is that the unused bit count is in the lower > three bits of p->flags, provided that ASN1_STRING_FLAG_BITS_LEFT is set. > This is

bgpctl fmt_timeframe cleanup

2022-06-23 Thread Claudio Jeker
Newer gcc likes to bitch about snprintf buffers being to small for insane numbers. This made me look at fmt_timeframe() and I decided to clean it up a bit. First of all the ring buffer is not needed. fmt_timeframe() is never used multiple time in a single printf() call. So drop that. Then make

bgpd move struct kif to kroute.c

2022-06-23 Thread Claudio Jeker
struct kif is internal to the kroute code with the exception of the 'depend on' tracking message. So create an extra object for this message and move struct kif to kroute.c. I renamed the IMSG just to make it clear what this is about and to make sure I did not miss something. After that struct

bgpd walks into IPv6 hell

2022-06-23 Thread Claudio Jeker
IPv6 is such a lovley protocol. Add the scope_id for link local addresses in kr6_tofull() because IPv6 just has to be "special". Maybe we should add a scope_id to struct kroute6 but heck it is mostly the interface index except for non link local addresses because there it has to be 0. So this

Re: ts(1): make timespec-handling code more obvious

2022-07-05 Thread Claudio Jeker
On Mon, Jul 04, 2022 at 05:10:05PM -0500, Scott Cheloha wrote: > On Mon, Jul 04, 2022 at 11:15:24PM +0200, Claudio Jeker wrote: > > On Mon, Jul 04, 2022 at 01:28:12PM -0500, Scott Cheloha wrote: > > > Hi, > > > > > > Couple things: > > > > > &g

Re: ts(1): make timespec-handling code more obvious

2022-07-05 Thread Claudio Jeker
On Tue, Jul 05, 2022 at 11:34:21AM +, Job Snijders wrote: > On Tue, Jul 05, 2022 at 11:08:13AM +0200, Claudio Jeker wrote: > > On Mon, Jul 04, 2022 at 05:10:05PM -0500, Scott Cheloha wrote: > > > On Mon, Jul 04, 2022 at 11:15:24PM +0200, Claudio Jeker wrote: > > > &

bgpd: assign local path_id to all prefixes

2022-07-07 Thread Claudio Jeker
This diff is assigning a local path_id to all prefixes. This path_id will be used for sending out add-path updates. Since the RFC specifies that the path_id has no meaning we assing the path_ids randomly. They just need to be unique per rib entry. Now this code assigne the path_id in the

bgpd: initial local path_id support for Adj-RIB-Out

2022-07-08 Thread Claudio Jeker
This diff adds the required plumbing to support local path_ids in the output path. Mainly it extends prefix_adjout_update() to do the right thing. Since in normal mode of operation path_id_tx does not matter and only on prefix is in the Adj-RIB-Out the code uses prefix_adjout_lookup() to locate

Re: arp getuptime

2022-06-27 Thread Claudio Jeker
On Mon, Jun 27, 2022 at 01:58:11PM +0200, Alexander Bluhm wrote: > Hi, > > Instead of calling getuptime() all the time in ARP code, I would > like to do it only once per function. This should give us a more > consistent time value. > > ok? I would love to see the arp code use rttimer instead

Re: Remove switch(4) leftovers

2022-06-27 Thread Claudio Jeker
On Mon, Jun 27, 2022 at 01:44:55PM +, Visa Hankala wrote: > Remove some switch(4) leftovers. > > OK? OK claudio > Index: etc/etc.hppa/MAKEDEV.md > === > RCS file: src/etc/etc.hppa/MAKEDEV.md,v > retrieving revision 1.68 > diff

Re: ts(1): make timespec-handling code more obvious

2022-07-04 Thread Claudio Jeker
On Mon, Jul 04, 2022 at 01:28:12PM -0500, Scott Cheloha wrote: > Hi, > > Couple things: > > - Use additional timespec variables to make our intent more obvious. > > Add "elapsed", "utc_offset", and "utc_start". > > "roff" is a confusing name, "utc_offset" is better. > > Yes, I know the

Re: Use SMR instead of SRP list in rtsock.c

2022-07-01 Thread Claudio Jeker
On Thu, Jun 30, 2022 at 03:46:35PM +, Visa Hankala wrote: > On Thu, Jun 30, 2022 at 11:51:52AM +0200, Claudio Jeker wrote: > > After discussing this with mpi@ and jmatthew@ we came to the conclusion > > that we need to smr_barrier() before refcnt_finalize() to ensure that n

Re: bgpctl adjust AID loops a bit

2022-07-08 Thread Claudio Jeker
On Fri, Jul 08, 2022 at 05:15:49PM +0200, Theo Buehler wrote: > On Fri, Jul 08, 2022 at 05:04:05PM +0200, Claudio Jeker wrote: > > I noticed that some of the loops over all AID (address identifiers) start > > at 0 but they should use AID_MIN. This is not a general rule and I >

bgpd: add add-path send support

2022-07-08 Thread Claudio Jeker
Add the missing bits for add-path send support. The config options allows for a fair amount of configuration and not all have been tested: announce add-path send best [ plus X ] announce add-path send ecmp [ plus X ] [ max Y ] announce add-path send as-wide-best [ plus X ]

bgpctl adjust AID loops a bit

2022-07-08 Thread Claudio Jeker
I noticed that some of the loops over all AID (address identifiers) start at 0 but they should use AID_MIN. This is not a general rule and I actually skipped one of the for loops because I think there 0 is actually better. In the cases I fixed it is known that only known AID and not AID_UNSPEC are

bgpd move struct kroute definition to kroute.c

2022-06-22 Thread Claudio Jeker
Both struct kroute and struct kroute6 are no longer used outside of kroute.c. As a first step move the definitions over to that file. More will follow :) -- :wq Claudio ? obj ? test ? test.c Index: bgpd.h === RCS file:

Re: bgpd/bgpctl use struct kroute_full in nexthop messages

2022-06-22 Thread Claudio Jeker
On Wed, Jun 22, 2022 at 04:37:44PM +0200, Theo Buehler wrote: > On Wed, Jun 22, 2022 at 04:13:43PM +0200, Claudio Jeker wrote: > > Do not leak the address family specific struct kroute into bgpctl if there > > is struct kroute_full which is address family independent. > >

bgpd use struct kroute_full for bgpd_filternexthop

2022-06-22 Thread Claudio Jeker
Instead of passing either a struct kroute or struct kroute6 pointer use kr_tofull() and use struct kroute_full. This makes the code in bgpd_filternexthop() a lot cleaner. -- :wq Claudio Index: bgpd.c === RCS file:

bgpd/bgpctl use struct kroute_full in nexthop messages

2022-06-22 Thread Claudio Jeker
Do not leak the address family specific struct kroute into bgpctl if there is struct kroute_full which is address family independent. The result is mostly minus because the code no longer needs address family specific code paths. This changes 'bgpctl show nexthop' but not its output. OK? -- :wq

rtsock change sysctl walker

2022-06-26 Thread Claudio Jeker
Switch the state variables to track the buffer size for the sysctl to size_t and stop using the somewhat strange way of working with the buf limit from starting with a negative w_needed. Just use the less confusing w_needed <= w_given as limit check. -- :wq Claudio Index: net/rtsock.c

bgpd document add-path send

2022-07-11 Thread Claudio Jeker
This is my try at documenting the just added add-path bits. -- :wq Claudio Index: bgpd.8 === RCS file: /cvs/src/usr.sbin/bgpd/bgpd.8,v retrieving revision 1.74 diff -u -p -r1.74 bgpd.8 --- bgpd.8 28 Jun 2022 11:52:24 -

Re: bgpd document add-path send

2022-07-12 Thread Claudio Jeker
On Mon, Jul 11, 2022 at 08:18:07PM +0100, Stuart Henderson wrote: > On 2022/07/11 19:12, Claudio Jeker wrote: > > This is my try at documenting the just added add-path bits. > > > > -- > > :wq Claudio > > > > +per prefix. > > +Which paths are sen

Re: Import ts(1) - a timestamp utility

2022-06-29 Thread Claudio Jeker
On Wed, Jun 29, 2022 at 09:50:39AM +, Job Snijders wrote: > On Wed, Jun 29, 2022 at 09:18:08AM +, Job Snijders wrote: > > Add a '-m' monotonic clock option > > I misunderstood what the moreutils ts -m option was doing, below is a > different version, which is 'resistant' against the

Use SMR instead of SRP list in rtsock.c

2022-06-30 Thread Claudio Jeker
This diff converts the SRP list to a SMR list in rtsock.c SRP is a bit strange with how it works and the SMR code is a bit easier to understand. Since we can sleep in the SMR_TAILQ_FOREACH() we need to grab a refcount on the route pcb so that we can leave the SMR critical section and then enter

Re: Use SMR instead of SRP list in rtsock.c

2022-06-30 Thread Claudio Jeker
On Thu, Jun 30, 2022 at 11:08:48AM +0200, Claudio Jeker wrote: > This diff converts the SRP list to a SMR list in rtsock.c > SRP is a bit strange with how it works and the SMR code is a bit easier to > understand. Since we can sleep in the SMR_TAILQ_FOREACH() we need to grab >

Re: TSO Large Send Offloading for ix(4)

2022-06-30 Thread Claudio Jeker
On Wed, Jun 29, 2022 at 02:24:35PM +0200, Jan Klemkow wrote: > Hi, > > This diff introduces the sending side of TSO to our TCP/IP stack. > If the hardware has TSO capabilities tcp_output() will send huge TCP > segments down the stack to the interface. ip{6}_output() will ignore > the size is

Re: Use SMR instead of SRP list in rtsock.c

2022-06-30 Thread Claudio Jeker
On Thu, Jun 30, 2022 at 03:21:40PM +0300, Vitaliy Makkoveev wrote: > On Thu, Jun 30, 2022 at 11:56:55AM +0200, Claudio Jeker wrote: > > On Thu, Jun 30, 2022 at 12:34:33PM +0300, Vitaliy Makkoveev wrote: > > > On Thu, Jun 30, 2022 at 11:08:48AM +0200, Claudio Jeker wrote: > >

Re: Use SMR instead of SRP list in rtsock.c

2022-06-30 Thread Claudio Jeker
On Thu, Jun 30, 2022 at 12:34:33PM +0300, Vitaliy Makkoveev wrote: > On Thu, Jun 30, 2022 at 11:08:48AM +0200, Claudio Jeker wrote: > > This diff converts the SRP list to a SMR list in rtsock.c > > SRP is a bit strange with how it works and the SMR code is a bit easier to > >

one send_rtmsg is enough for bgpd

2022-06-30 Thread Claudio Jeker
Implement send_rtmsg() using kroute_full and just use one version of this magical code. I use struct sockaddr_storage for all sockaddrs added to ensure that there is a) enough space and b) that ROUNDUP() does not cause the system to pass uninitialized stack memory to the kernel. I tested IPv4 and

time pTS(1)d

2022-06-29 Thread Claudio Jeker
So ts(1) with -i or -s prints strange numbers when used with either %T or %s (the current timezone comes into play and you end up in pain). This diff cleans up the code, forces UTC for -i or -s and simplifies a lot of the code. I think with this things like TZ=Canada/Newfoundland ts -s %.T and

bgpd: refactor update generation a bit

2022-07-06 Thread Claudio Jeker
This diff changes various loops which call into up_generate_update() so that all these loops call the same function peer_generate_update() which then calls up_generate_update(). This is a step to add an alternative path to generate updates for add-path send support without altering many

Re: ts(1): make timespec-handling code more obvious

2022-07-06 Thread Claudio Jeker
On Tue, Jul 05, 2022 at 07:04:49AM -0500, Scott Cheloha wrote: > On Tue, Jul 05, 2022 at 11:53:26AM +0200, Claudio Jeker wrote: > > On Tue, Jul 05, 2022 at 11:34:21AM +, Job Snijders wrote: > > > On Tue, Jul 05, 2022 at 11:08:13AM +0200, Claudio Jeker wrote: > > > &

Re: bgpd: refactor update generation a bit

2022-07-06 Thread Claudio Jeker
On Wed, Jul 06, 2022 at 06:15:45PM +0200, Theo Buehler wrote: > On Wed, Jul 06, 2022 at 05:07:45PM +0200, Claudio Jeker wrote: > > This diff changes various loops which call into up_generate_update() so > > that all these loops call the same function peer_generate_update() which

bgpd kroute_node cleanup

2022-06-22 Thread Claudio Jeker
Diff is huge but mostly mechanical. Remove kroute_node, kroute6_node and use struct kroute and kroute6 directly. Also do a similar dance for struct knexthop_node. I left kredist_node and kif_node for now since this diff is already large enough. -- :wq Claudio Index: bgpd.h

bgpd use more portable IPv6 magic mushrooms

2022-06-24 Thread Claudio Jeker
It seems that IN6_IS_ADDR_MC_INTFACELOCAL() is actually spelled IN6_IS_ADDR_MC_NODELOCAL(). So better use that for portability. -- :wq Claudio Index: kroute.c === RCS file: /cvs/src/usr.sbin/bgpd/kroute.c,v retrieving revision

bgpd: refactor kroute code a fair bit

2022-06-08 Thread Claudio Jeker
The idea behind this diff is to use struct kroute_full in more places. Mainly when parsing route messages. This allows to factor out the pure route message parsing into dispatch_rtmsg_addr() and use it in both the gerneral routing socket code but also in fetchtables(). Which removes some

bgpd fix for undefined macros

2022-06-09 Thread Claudio Jeker
Fix a crash because of a NULL pointer dereference in parse.y Before: /etc/bgpd.conf:85: macro 'UNDEFINED' not defined Segmentation fault After: /etc/bgpd.conf:85: macro 'UNDEFINED' not defined /etc/bgpd.conf:85: syntax error -- :wq Claudio Index: parse.y

Re: bgpd: refactor kroute code a fair bit

2022-06-08 Thread Claudio Jeker
On Wed, Jun 08, 2022 at 06:10:21PM +0200, Theo Buehler wrote: > On Wed, Jun 08, 2022 at 01:28:14PM +0200, Claudio Jeker wrote: > > The idea behind this diff is to use struct kroute_full in more places. > > Mainly when parsing route messages. This allows to factor out the pure &g

set RTF_DONE in sysctl_dumpentry for the routing table

2022-06-08 Thread Claudio Jeker
Notice while hacking in OpenBGPD. Unlike routing socket messages the messages from the sysctl interface have RTF_DONE not set. I think it would make sense to set RTF_DONE also in this case since it makes reusing code easier. All messages sent out via sysctl_dumpentry() have been processed by the

Re: rpki-client: dedup econtent version checks

2022-06-10 Thread Claudio Jeker
On Fri, Jun 10, 2022 at 11:38:53AM +0200, Theo Buehler wrote: > On Fri, Jun 10, 2022 at 11:31:42AM +0200, Theo Buehler wrote: > > This is a leftover of the conversion to ASN.1 templates. The diff > > reinstates a simplified variant of the removed cms_econtent_version(). > > > > None of the

Re: bgpd: refactor kroute code a fair bit

2022-06-08 Thread Claudio Jeker
On Wed, Jun 08, 2022 at 06:27:36PM +0200, Claudio Jeker wrote: > On Wed, Jun 08, 2022 at 06:10:21PM +0200, Theo Buehler wrote: > > On Wed, Jun 08, 2022 at 01:28:14PM +0200, Claudio Jeker wrote: > > > The idea behind this diff is to use struct kroute_full in more places. > &g

bgpd: cleanup fib_priority

2022-06-03 Thread Claudio Jeker
fib_priority was slapped into the code by passing it around all the time. It is much smarter to use a global value in kr_state for the fib_prio and then tag F_BGP_INSERTED routes with RTP_MINE (0xff) which is an impossible RTP value. With that changing the prio requires "only" a fib decouple,

Re: relayd panic

2022-06-06 Thread Claudio Jeker
On Mon, Jun 06, 2022 at 12:03:06AM +0200, Alexandr Nedvedicky wrote: > Hello, > > I'll commit one-liner diff on Tuesday morning (Jun 6th) Prague time without > explicit OK, unless there will be no objection. The diff is OK claudio@. > regards > sashan > > > On Sun, Jun 05, 2022 at 09:44:45AM

bgpd, retire F_RTLABEL flag

2022-06-07 Thread Claudio Jeker
The F_RTLABEL flag does nothing. So just remove it. Checking the rtlabelid != 0 is equivalent. -- :wq Claudio Index: bgpd.h === RCS file: /cvs/src/usr.sbin/bgpd/bgpd.h,v retrieving revision 1.426 diff -u -p -r1.426 bgpd.h ---

Re: bgpd, fix some rtlabel leaks

2022-06-07 Thread Claudio Jeker
On Tue, Jun 07, 2022 at 06:21:37PM +0200, Theo Buehler wrote: > On Tue, Jun 07, 2022 at 05:49:53PM +0200, Claudio Jeker wrote: > > The kroute code can leak rtlabel references in various conditions. > > In the end we want to drop the reference before free(). > > So move the unr

Re: bgpd, retire F_RTLABEL flag

2022-06-07 Thread Claudio Jeker
On Tue, Jun 07, 2022 at 05:47:52PM +0200, Theo Buehler wrote: > On Tue, Jun 07, 2022 at 05:09:30PM +0200, Claudio Jeker wrote: > > The F_RTLABEL flag does nothing. So just remove it. > > Checking the rtlabelid != 0 is equivalent. > > Doesn't twiddling the F_RTLABEL potential

bgpd, fix some rtlabel leaks

2022-06-07 Thread Claudio Jeker
The kroute code can leak rtlabel references in various conditions. In the end we want to drop the reference before free(). So move the unref into kroute_remove() so it is done mostly in one place. On top fix a few other places where kroutes are freed. This diff is on top of the previous diff

Re: bgpd more kroute cleanup

2022-06-15 Thread Claudio Jeker
On Tue, Jun 14, 2022 at 08:14:45PM +0200, Theo Buehler wrote: > On Tue, Jun 14, 2022 at 06:36:13PM +0200, Claudio Jeker wrote: > > This diff does introduce a new flag for routes that have been inserted > > into the FIB. Now I actually renamed the F_BGPD_INSERTED flag to F_BGPD

don't depend on pfkeyv2.h in portable bgpd code

2022-06-15 Thread Claudio Jeker
So pfkeyv2.h defines managed to sneak into the portable part of bgpd. The fix was to just dump a pfkeyv2.h version into the -portable compat code and call it a day. This is bad since pfkeyv2.h is highly OS dependent. This diff cleans up the mess by introducing new enums for the various IPsec

bgpd prevent infinite-loop in pfkey code

2022-06-15 Thread Claudio Jeker
Found by accident. If the pfkey message failed (sadb_msg_errno is set) then the pfkey code ends in an infinite loop because the erroneous message is not removed from the queue. pfkey_read() PEEKS at the message and returns 0 since it is what we expect. pfkey_reply() realizes it is an error and

bgpd: next round of kroute cleanup

2022-06-16 Thread Claudio Jeker
This diff kills external use of prefixlen2mask() and uses inet4applymask() instead. With this the IPv4 and IPv6 code is more similar. Also I feel the code is a bit easier to read. Also kroute{,6}_match() is changed to take a struct bgpd_addr *. This is another step towards removing lots of copy

bgpd name2id change

2022-06-16 Thread Claudio Jeker
tb@ noticed that name2id conversions never check for error. Now I think this is fine but in that case the api should not do a half assed job of setting errnos. In the end if 0 is returned from name2id but the input was not the empty string then an error occurred. None of the callers does this

bgpd switch kroute_find to bgpd_addr argument

2022-06-16 Thread Claudio Jeker
Not much holds us back to switch kroute_find() to use a struct bgpd_addr as prefix argument. Only the match code needs some adoption. I created applymask() for this which works on bgpd_addrs like inet4applymask works on in_addrs. I also switched a simple case in session.c over to applymask().

bgpd: cleanup warnings in pfkey

2022-06-16 Thread Claudio Jeker
There is no reason to add the __func__ in this warning. It is just clutter in the error message with no benefit. OK to remove? -- :wq Claudio Index: pfkey.c === RCS file: /cvs/src/usr.sbin/bgpd/pfkey.c,v retrieving revision 1.64

Re: bgpd: next round of kroute cleanup

2022-06-16 Thread Claudio Jeker
On Thu, Jun 16, 2022 at 03:28:58PM +0200, Theo Buehler wrote: > On Thu, Jun 16, 2022 at 02:36:28PM +0200, Claudio Jeker wrote: > > This diff kills external use of prefixlen2mask() and uses inet4applymask() > > instead. With this the IPv4 and IPv6 code is more similar. > >

fix KAME hack in bgpd sa2addr()

2022-06-16 Thread Claudio Jeker
Copy the version of the __KAME__ hack from route/show.c and more importantly copy the address after modifying the sa. This only affects IPv6 link local addresses which are not really used by bgpd. Still happy if a few more people can give this a spin. -- :wq Claudio ? obj Index: util.c

Re: bgpd switch kroute_find to bgpd_addr argument

2022-06-17 Thread Claudio Jeker
On Thu, Jun 16, 2022 at 09:01:33PM +0200, Theo Buehler wrote: > On Thu, Jun 16, 2022 at 07:15:51PM +0200, Claudio Jeker wrote: > > Not much holds us back to switch kroute_find() to use a struct bgpd_addr > > as prefix argument. Only the match code needs some adoption. > >

Re: bgpd switch kroute_find to bgpd_addr argument

2022-06-17 Thread Claudio Jeker
On Fri, Jun 17, 2022 at 12:32:50PM +0200, Theo Buehler wrote: > On Fri, Jun 17, 2022 at 11:37:29AM +0200, Claudio Jeker wrote: > > On Thu, Jun 16, 2022 at 09:01:33PM +0200, Theo Buehler wrote: > > > On Thu, Jun 16, 2022 at 07:15:51PM +0200, Claudio Jeker wrote: > > &g

bgpctl use applymask()

2022-06-19 Thread Claudio Jeker
This diff uses applymask() instead of the IPv4 and IPv6 version. Makes the code a tiny bit simpler. -- :wq Claudio Index: parser.c === RCS file: /cvs/src/usr.sbin/bgpctl/parser.c,v retrieving revision 1.111 diff -u -p -r1.111

bgpd more kroute cleanup

2022-06-14 Thread Claudio Jeker
This diff does introduce a new flag for routes that have been inserted into the FIB. Now I actually renamed the F_BGPD_INSERTED flag to F_BGPD and reused F_BGPD_INSERTED as this new flag. Adjust and use the send_rtmsg() return value to set F_BGPD_INSERTED if the route message was successfully

OpenBGPD 7.4 released

2022-06-14 Thread Claudio Jeker
We have released OpenBGPD 7.4, which will be arriving in the OpenBGPD directory of your local OpenBSD mirror soon. This release includes the following changes to the previous release: * Implement max-communities filter to limit the number of allowed communities, ext-communities and

Re: bgpd: refactor kroute code a fair bit

2022-06-09 Thread Claudio Jeker
On Thu, Jun 09, 2022 at 02:54:28PM +0200, Theo Buehler wrote: > On Wed, Jun 08, 2022 at 10:47:48PM +0200, Claudio Jeker wrote: > > and here is the updated diff I forgot to include > > I think I've now done what I reasonably can do to review this. I buy > that this mostly

Re: bgpd: refactor kroute code a fair bit

2022-06-09 Thread Claudio Jeker
On Thu, Jun 09, 2022 at 09:47:31AM +0100, Stuart Henderson wrote: > On 2022/06/08 22:47, Claudio Jeker wrote: > > and here is the updated diff I forgot to include > > Not sure if it's expected / not, but I lose interface information > with this: > > > $ diff -wu old

more bgpd kroute cleanup

2022-06-09 Thread Claudio Jeker
Noticed that similar to fib_prio the rdomain id is passed around to some places where it really makes no sense. First of all kr_nexthop_add() and kr_nexthop_delete() can be simplified. The imsg peerid is always 0. This was added in the beginning of L3VPN support without realizing that all bgp

bgpd, plug rtlabel refcount leak on network statements

2022-07-20 Thread Claudio Jeker
Found while working on kroute code. The network structs needs to release the rtlabel reference before being freed. -- :wq Claudio Index: config.c === RCS file: /cvs/src/usr.sbin/bgpd/config.c,v retrieving revision 1.102 diff -u -p

bgpd, network code cleanup

2022-07-20 Thread Claudio Jeker
The it's just a rtlabel refcount leak diff turned into a somewhat larger diff. First I noticed that expand_networks() was not used for l3vpns which will cause problems down the line. So alter expand_networks to also handle l3vpn network settings. Then I looked at kr_net_reload() and kr_net_find()

Re: bgpd, refactor kroute_insert

2022-07-20 Thread Claudio Jeker
On Wed, Jul 20, 2022 at 10:56:29AM +0200, Claudio Jeker wrote: > This diff moves kroute_insert to use struct kroute_full and do the > allocation for struct kroute / kroute6 inside kroute_insert. This removes > a lot of similar code all over kroute.c. While doing that also convert > kr_

bgpd, refactor kroute_insert

2022-07-20 Thread Claudio Jeker
This diff moves kroute_insert to use struct kroute_full and do the allocation for struct kroute / kroute6 inside kroute_insert. This removes a lot of similar code all over kroute.c. While doing that also convert kr_redistribute() to use struct kroute_full and kill the code duplication there as

Re: bgpd, plug rtlabel refcount leak on network statements

2022-07-20 Thread Claudio Jeker
On Wed, Jul 20, 2022 at 11:00:00AM +0200, Theo Buehler wrote: > On Wed, Jul 20, 2022 at 10:35:10AM +0200, Claudio Jeker wrote: > > Found while working on kroute code. The network structs needs to release > > the rtlabel reference before being freed. > > Don't expand_network

bgpd less chatter on rde exit

2022-07-18 Thread Claudio Jeker
Noticed the other day, when the RDE dies the session engine may log the "Can't send message %u to RDE, ctl pipe closed" multiple times because the queue is still processed. Since this error only happens after a "SE: Lost connection to RDE" error it does not anything to the crash log. This is why

Re: bgpd decision process and bad dmetric

2022-07-16 Thread Claudio Jeker
On Sat, Jul 16, 2022 at 01:51:58PM +0200, Theo Buehler wrote: > On Sat, Jul 16, 2022 at 12:41:07PM +0200, Claudio Jeker wrote: > > I deployed bgpd on one of more core routers and triggered the fatal > > "bad dmetric in decision process" from time to time. > >

bgpd aspath_extract overflow check

2022-07-19 Thread Claudio Jeker
aspath_extract() should do at least a minimal overflow check and not access memory after the segment. Can't use fatalx here because bgpctl also uses this function. Instead return 0, that is an invalid ASN. No code will check the return value but that is fine since all callers ensure that pos does

bgpd name struct kroute_full vars kf

2022-07-19 Thread Claudio Jeker
Use kf for all struct kroute_full variables in bgpd. This makes the code more consistent. -- :wq Claudio Index: kroute.c === RCS file: /cvs/src/usr.sbin/bgpd/kroute.c,v retrieving revision 1.273 diff -u -p -r1.273 kroute.c ---

Re: bgpd aspath_extract overflow check

2022-07-19 Thread Claudio Jeker
On Tue, Jul 19, 2022 at 12:31:47PM +0200, Theo Buehler wrote: > On Tue, Jul 19, 2022 at 11:43:25AM +0200, Claudio Jeker wrote: > > aspath_extract() should do at least a minimal overflow check and not > > access memory after the segment. Can't use fatalx here because bgpct

Re: bgpd, refactor kroute_insert

2022-07-21 Thread Claudio Jeker
On Thu, Jul 21, 2022 at 12:03:27PM +0200, Theo Buehler wrote: > On Thu, Jul 21, 2022 at 11:10:41AM +0200, Claudio Jeker wrote: > > On Wed, Jul 20, 2022 at 12:28:25PM +0200, Claudio Jeker wrote: > > > On Wed, Jul 20, 2022 at 10:56:29AM +0200, Claudio Jeker wrote: >

bgpd, relax setting rde evaluate all and add-path send

2022-07-21 Thread Claudio Jeker
rde evaluate all and add-path send do not really work together. add-path will evaluate extra paths (if plus is used) and so it implies a mode of `rde evaluate all`. I added the exclusion mainly to make it clear that the two don't really mix. After a request from Pier Carlo Chiodi on

Re: bgpd, refactor kroute_insert

2022-07-21 Thread Claudio Jeker
On Wed, Jul 20, 2022 at 12:28:25PM +0200, Claudio Jeker wrote: > On Wed, Jul 20, 2022 at 10:56:29AM +0200, Claudio Jeker wrote: > > This diff moves kroute_insert to use struct kroute_full and do the > > allocation for struct kroute / kroute6 inside kroute_insert. This removes >

bgpd: fix nexthop state bug in decision process

2022-07-25 Thread Claudio Jeker
The nexthop validation or actually invalidation is buggy in bgpd since revision 1.90 of rde_decide.c. When I removed re->active and replaced it with a value that is calculated on the spot I did not realize that this calculation depends on the current nexthop state and not on the state used on the

<    13   14   15   16   17   18   19   20   21   22   >