rpki-client: rework aspa_insert_vaps()
The merge loop in aspa_insert_vaps() is too smart and has tripped us all up
repeatedly. While it won't matter much due to size constraints, its worst
case is O(n*m), which isn't great.
Let's make this easier to follow and reason about. A linear sweep merges
and deduplicates the two arrays question until one of them is consumed,
then fill in the tail of the one that remains non-empty. Both arrays are
strictly monotonic, and this property is clearly preserved by the new
approach.
The other bit that is obvious is that the merge loop is O(n + m). The price
we pay is a bit more code and an extra allocation.
ok claudio job
In tlv_decode_fec_elm add missing initial len and prefixlen check
Ensure that fec_elm have at least the one byte needed for the type
and also check that the encoded prefixlen actually matches with the
address family.
Reported by Yang Hailong
OK deraadt@ tb@
rpki-client: fix merging of ASPA objects
Prompted by a question by Yangyang WANG, draft-ietf-sidrops-aspa-profile-29
added new wording regarding 0 handling when merging two ASPAs with the same
customer ASID and clarified that 0 should be discarded:
https://mailarchive.ietf.org/arch/msg/sidrops/TToTScyLiVXdyJzf-kgzv5XMy3U/
Implement this and adjust the accounting when dropping the 0.
Found by job because this case now appears in the wild.
ok claudio
stop checking for if_type == IFT_IEEE8023ADLAG everywhere.
trunk no longer overwrites the if_type on ports, so it's not going
to be IFT_IEEE8023ADLAG.
in particular this fixes packet reception on trunk interfaces.
found by and fixed tested by landry@
restore port interface function state in a better order.
removing the ether_port before fixing the if_ioctl pointer, and
especially when doing ioctls in between those two things, trips
KASSERTS.
bug reported and fix tested by landry@
Sync with ometric from rpki-client: Sort union by size
The initalizers introduced in C99 may only initialize the first
element of a union. If that one is not the largest member
then you may end up with uninitalized memory. In the end the
outcome depends on the compiler used which is just bananas.
don't have bpf_detachd give up the bd mtx to call ifpromisc.
instead, have it return an interface reference and make the caller
responsible for the ifpromisc call. this gets rid of window that
releasing the bd mtx opens and the NET_LOCK call for ifpromisc opens.
that window allows allows an interface we're trying to attach to
in bpf_setif, or switch dlts on in bpf_setdlt, to be removed from
the system before bpf can properly account for it. so we need to
keep the bd mtx hold.
found by tom smyth whoe also tested a few versions of this diff.
i missed a chunk when getting rid of the IFT_IEEE8023ADLAG fiddling
trunk_port_ioctl was checking that IFT_IEEE8023ADLAG was set on the
port, which isnt true anymore.
dont switch if_type to IFT_IEEE8023ADLAG on ports anymore.
if_type should be immutable and set by the driver providing the
interface.
from what i can tell, the main reason to do this was to mark an
interfaces as "in use" by trunk, but we can figure that out by using
ac_trport now.
don't let a vxlan interface set itself as the parent.
fixes part of the problems in the "vxlan(4): vxlan accepted as its
own parent" email tom smyth sent to bugs@
this doesnt prevent configuration of interface topologies with
loops, but it's a good start.
don't let an nvgre interface set itself as the parent.
fixes part of the problems in the "gre(4): nvgre accepted as its
own parent" email tom smyth sent to bugs@
this doesnt prevent configuration of interface topologies with
loops, but it's a good start.
vfs: set cn_pnbuf to NULL after pool_put in vfs_generic_abortop. This
can be called in a variety of error paths and by explicitly NULLing this
and not clearing HASBUF this ensures a panic on reuse rather than a
potential UAF.
There are no known paths to this currently, this is a hardening only.
ok deraadt@ kirill@ beck@
don't assume the new interface being patched is pair until the end.
care has to be taken to still release the requested ifnet reference,
regardless of whether it is a pair or not.
this should fix the 'pair(4): "patch" to a non-pair interface panics
(lo) or downs its link' problem reported by tom smyth on bugs@
check that the interface being paired is a pair(4) before fiddling with it
before this it was looking into the pair_softc of the new interface
before making sure it was a pair(4) first.
ok mvs@
use if_drvid to ensure pair is only paired with other pair ifaces
this was doing some complicated stuff with if_clone_lookup and
strcmp to get the same result, but this is a lot simpler.
ok mvs@ as part of a larger diff.
use if_drvid to identify vport interface instances.
veb treats vports specially, so it needs a way to identify which
interfaces are backed by the vport driver, which is what if_drvid
provides. this replaces using an ifnet function pointer to imply
which driver backs an interface, which is brittle.
ok mvs@ as part of a bigger diff.
use if_drvid to ensure rports are only paired with rports.
i was using the if_enqueue function point for this, but i want to
replace if_enqueue with a more generic function in the future which
would break this.
part of a larger diff that was ok mvs@