Commit Graph

3046 Commits

Author SHA1 Message Date
riastradh 076e35792d if_attach and if_initialize cannot fail, don't test return value
These were originally made failable back in 2017 when if_initialize
allocated a softint in every interface for link state changes, so
that it could fail gracefully instead of panicking:

https://mail-index.NetBSD.org/source-changes/2017/10/23/msg089053.html

However, this spawned many seldom- or never-tested error branches,
which are risky to have around.  And that softint in every interface
has since been replaced by a single global workqueue, because link
state changes require thread context but not low latency or high
throughput:

https://mail-index.NetBSD.org/source-changes/2020/02/06/msg113759.html

So there is no longer any reason for if_initialize to fail.  (The
subroutine if_stats_init can't fail because percpu_alloc can't fail
either.)

There is a snag: the softint_establish in if_percpuq_create could
fail, potentially leading to bad consequences later on trying to use
the softint.  This change doesn't introduce any new bugs because of
the snag -- if_percpuq_attach was already broken.  However, the snag
can be better addressed without spawning error branches, either by
using a single softint or making softints less scarce.

(Separate commit will change the signatures of if_attach and
if_initialize to return void, scheduled to ride whatever is the next
convenient kernel bump.)

Patch and testing on amd64 and evbmips64-eb by maya@; commit message
soliloquy, and compile-testing on evbppc/i386/earmv7hf, by me.
2021-06-16 00:21:17 +00:00
christos 9c9223617d Move the offset addition in one place and mask the random generated value
to make sure that the isn is monotonic.
2021-03-09 13:48:16 +00:00
christos c67373b162 mv <sys/cprng.h> include to the kernel portion 2021-03-08 22:01:18 +00:00
christos fd63f5967c reinstate a simple version of ip_randomid() 2021-03-08 20:01:54 +00:00
christos 2f7bd7704b Remove the unused "addin" argument (it was always 0) and go back using
a random iss by default (instead of rfc1948)
2021-03-08 18:17:27 +00:00
christos aa44bcfbff remove now unused pseudo-random ip id code. 2021-03-08 18:03:25 +00:00
christos fa908c0b8c Add some randomness to the iss offset 2021-03-08 17:54:43 +00:00
christos a07b5793ea Use a random IPv4 ID because the shuffling algorithm used before could expose
information (Amit Klein)
2021-03-08 17:54:23 +00:00
christos 32fcdf5a4e Don't increment the iss sequence on each connection because it exposes
information (Amit Klein)
2021-03-08 17:53:20 +00:00
christos 4b58b6c56b netinet/netinet6: Add necessary includes to make these standalone.
(from riastradh)
2021-03-07 15:01:00 +00:00
christos e4aa255bad netinet: Enable RFC 1948 pseudorandom TCP ISS selection by default.
(from riastradh)
2021-03-07 14:58:54 +00:00
christos 5d948faaec netinet: Enable random IP fragment ids by default (from riastradh) 2021-03-07 14:58:27 +00:00
jakllsch 6c1cfa34fb it's spelled struct tcphdr, not struct tcp_hdr 2021-02-19 15:43:56 +00:00
christos 2143da8717 - Make ALIGNED_POINTER use __alignof(t) instead of sizeof(t). This is more
correct because it works with non-primitive types and provides the ABI
  alignment for the type the compiler will use.
- Remove all the *_HDR_ALIGNMENT macros and asserts
- Replace POINTER_ALIGNED_P with ACCESSIBLE_POINTER which is identical to
  ALIGNED_POINTER, but returns that the pointer is always aligned if the
  CPU supports unaligned accesses.
[ as proposed in tech-kern ]
2021-02-19 14:51:59 +00:00
christos fc0eb449a4 - pass the alignment instead of the mask (as Roy asked and to match the
other macro)
- use alignof to determine that alignment and CTASSERT what we expect
- remove unused macros
2021-02-17 22:32:04 +00:00
martin b2f1163792 One more time: backout arp header alignment, now that the alignment
asserted has been aligned to reality.
Also remove unused ARP_HDR_ALIGNED_P macro. Pointed out by roy.
2021-02-16 10:22:52 +00:00
martin aee51c4b29 Undo previous backout: alignment is needed here.
The reason for the previous backout was a misunderstanding (POINTER_ALIGNED_P
was broken, but the assertion fired even after it got fixed).
2021-02-16 05:44:13 +00:00
christos 9a1851622c Undo previous; POINTER_ALIGNED_P was broken. 2021-02-15 19:49:17 +00:00
christos 356b4fcb30 put back alignment (reported by martin@) 2021-02-15 19:19:29 +00:00
knakahara 94b86f7d95 Fix build failure for options GATEWAY. 2021-02-15 03:41:01 +00:00
christos 9183889817 - centralize header align and pullup into a single inline function
- use a single macro to align pointers and expose the alignment, instead
  of hard-coding 3 in 1/2 the macros.
- fix an issue in the ipv6 lt2p where it was aligning for ipv4 and pulling
  for ipv6.
2021-02-14 20:58:34 +00:00
roy 2a093b6406 if_arp: Just KASSERT that arphrd is aligned
While here improve readability of checking ARP IEEE1394 matches interface.
2021-02-14 19:47:16 +00:00
roy cb6917aa0d Prior alignment fixes should not use an offset 2021-02-13 13:00:16 +00:00
roy dd39d07da7 if_arp: Ensure that arphdr is aligned 2021-02-13 07:57:09 +00:00
roy f217990197 CTASSERT -> __CTASSERT to unbreak userland build.
While here move __packed in tcp_debug.h back to where it was and
note removal warrants more investigation.
2021-02-03 18:13:13 +00:00
roy 157195c85e Guard CTASSERT 2021-02-03 17:10:13 +00:00
roy 7a849d032c Sprinkle CTASSERT to enforce on-wire layout without __packed 2021-02-03 11:53:43 +00:00
roy 2921174865 tcp_debug: restore __packed 2021-02-03 11:52:23 +00:00
roy 1ca39e8727 Remove __packed from various network structures
They are already network aligned and adding the __packed attribute
just causes needless compiler warnings about accssing members of packed
objects.
2021-02-03 05:51:40 +00:00
yamt 113b5fa6d9 arp: Plug an mbuf leak 2021-02-02 10:48:33 +00:00
thorpej ad62715351 Build ip_sync.c with -Wno-error to avoid failing due to excessive stack
usage.
2020-12-04 00:44:39 +00:00
chs 1777f82ff3 Restore correct functioning of SIOCATMARK by removing the previous
change that was done to fix poll(POLLPRI | POLLRDBAND) and instead
add a separate flag to track when poll() should indicate that a
MSG_OOB byte is available.  Re-fixes PR 54435 properly.
2020-11-23 00:52:53 +00:00
kardel 4794d48d5e PR kern/55779:
restore non-desctructive guarantee of ip_mforward() mbuf
argument. This avoids generation invalid UDP checksums
on multicast packets in ip_output().

XXX the root cause of the misguided fix in 2008 should be
XXX investigated
2020-11-12 13:13:45 +00:00
mlelstv 77730fa866 Fix RTT values reported by TCP_INFO. 2020-10-17 08:50:38 +00:00
roy 69c88affdd carp: Don't set a link level address if vhid == -1
Link level address for carp is dervied from vhid.
Until vhid is set, carp is useless, so don't give it a link level address
until a vhid is set.

This fixes recent test case breakage where carp was fixed to actually
print the ethernet address set by default. Note that neither carp nor
the test case itself was actually broken as the error is the common
ATF net code assuming that a cloned interface's link level address is
unique upon creation.
2020-10-14 13:43:56 +00:00
roy 30ba5d0082 carp: link state is DOWN until it becomes a MASTER
This is consitent with other BSD's handling of CARP and means
we don't have to carry a custom flag for it.
2020-10-12 15:18:48 +00:00
roy 37008ba264 carp: Set ethernet address just before interface registation
Otherwise ifconfig reports SIOCGLIFADDR errors.
2020-10-12 11:07:27 +00:00
roy db66d588fe carp: Remove media, software should use link status.
carp literally has no media just like ppp, vlan, etc.
2020-10-09 08:10:41 +00:00
roy 76faeff505 inet: Treat LINK_STATE_UNKNOWN as LINK_STATE_UP when changing
It's something we have always done.
it's really rare for anything to transition to UNKNOWN from either
UP or DOWN, but technically it is possible.
2020-09-29 19:33:36 +00:00
msaitoh 57920690e6 s/occurence/occurrence/ 2020-09-29 02:58:51 +00:00
roy e53a363e2b Implement RFC 7048, making Neighbor Unreachability Detection less impatient
RFC 7048 Section 3 says in the UNREACHABLE state packets continue to be
sent to the link-layer address and then backoff exponentially.
We adjust this slightly and move to the INCOMPLETE state after
`nd_mmaxtries` probes and then start backing off.

This results in simpler code whilst providing a more robust model which
doubles the time to failure over what we did before.
We don't want to be back to the old ARP model where no unreachability
errors are returned because very few applications would look at
unreachability hints provided such as ND_LLINFO_UNREACHABLE or RTM_MISS.
2020-09-15 10:05:36 +00:00
roy 20c15691a3 nd: Name l3addr union of llentry and use in-place of nd_addr.
Probably makes more sense and makes nd.h less messy.
2020-09-14 15:09:57 +00:00
roy fa0b4016c0 inet: Fix build without ARP 2020-09-13 11:47:12 +00:00
roy 3a97901738 inet: Add SIOCGNBRINFO to retrieve neighbor state about an address 2020-09-11 15:22:12 +00:00
roy 76d9d68816 in: No need to set expire here anymore 2020-09-11 15:19:31 +00:00
roy caccb5729a ARP: Use ND rather than our own.
This brings the benefit of Neighbour Unreachability Detection which is
something ARP sorely lacks.

The new timings mirror those of IPv6 and are adjustable via sysctl(8).
Unlike IPv6 ND, these are global and not per interface.
2020-09-11 15:16:00 +00:00
roy e4cfbe4044 tcp_input: Adjust for ND changes 2020-09-11 15:08:25 +00:00
kardel c0252f50ee PR/kern 55567
fix the data-only fast path. RCV.UP and SND.WL1 could be left behind
on long sequences of data only packets. pull them along to avoid relative
sequence wraps.

consistent with FreeBSD

addresses second failure mode of PR/kern 55567.

pullup to netbsd-8
pullup to netbsd-9
2020-09-11 09:08:47 +00:00
christos e5e40d965d Add IP_BINDANY, IPV6_BINDANY which can be used to bind to any address in
order to implement transparent proxies.
2020-09-08 14:12:57 +00:00
kardel eff3797159 Fix fast path for uni directional transfers
pure ACK case:

drag snd_wl2 along so only newer
ACKs can update the window size.
also avoids the state where snd_wl2
is eventually larger than th_ack and thus
blocking the window update mechanism and
the connection gets stuck for a loooong
time in the zero sized send window state.

see PR/kern 55567

ok thorpej@, also found in FreeBSD
2020-09-02 15:08:46 +00:00