Commit Graph

1913 Commits

Author SHA1 Message Date
kamil
4a75a43f8c Revert regression introduced in in6.h r. 1.95
----------------------------
revision 1.95
date: 2019-05-28 05:56:46 +0200;  author: kamil;  state: Exp;  lines: +2 -2;  commitid: YrUzDYl5zfcjiVoB;
Decorate struct in6_addr with the __packed attribute

This avoids undefined behavior when accessing misaligned pointers.

Detected by kUBSan.

Patch by Akul Pillai.
----------------------------

This change caused regression in at least qemu and addresses potential binary ABI breakage.

Fixes PR/54523 by <gson>
2019-09-05 20:17:27 +00:00
roy
ca7497cb84 inet6: Re-introduce ND6_LLINFO_WAITDELETE so we can return EHOSTDOWN
Once we've sent nd6_mmaxtries NS messages, send RTM_MISS and move to the
ND6_LLINFO_WAITDELETE state rather than freeing the llentry right away.
Wait for a probe cycle and then free the llentry.

If a connection attempts to re-use the llentry during ND6_LLINFO_WAITDELETE,
return EHOSTDOWN (or EHOSTUNREACH if a gateway) to match inet behaviour.
Continue to ND6_LLINFO_INCOMPLETE and send another NS probe in hope of a
reply. Rinse and repeat.

This reverts part of nd6.c r1.14 - an 18 year old commit!
2019-09-01 19:26:21 +00:00
roy
ca19b5765e inet6: Send RTM_MISS when we fail to resolve an address.
Takes the same approach as when adding a new address - we no longer
announce the new lladdr right away but we announce the result.
This will either be RTM_ADD or RTM_MISS.
RTM_DELETE is only sent if we have a lladdr assigned OR gc'ed.

This results in less messages via route(4) and tells us when a new
lladdr has been added (RTM_ADD), changed (RTM_CHANGE), deleted (RTM_DELETED)
or has failed to been resolved (RTM_MISS). The latter case can be
interpreted as unreachable.
2019-09-01 18:54:38 +00:00
roy
b8c808c559 inet6: don't set an invalid lladdr in nd6_free()
We don't want to announce that we've deleted a hwaddr of all zeros.
2019-08-31 01:49:45 +00:00
roy
511e6e8266 inet6: Revert prior
It's not needed, listing to RA is enough as discussed on tech-net.
2019-08-30 08:40:25 +00:00
roy
4b9c1dc098 Userland really has no business with NA messages.
However, RFC 4861 6.2.5 only says departing routers
*SHOULD* send RA with lifetime of zero and *MUST*
send all subsequent NA messages if the router flag
unset.

To help userland avoid the expensive process of
parsing NA messages, send RTM_CHANGE without a
lladdr in the gateway.
This is different from the intial RTM_ADD also
without a lladdr in the gateway and RTM_DELETE.
2019-08-29 16:26:43 +00:00
roy
a1b7f5f1b5 more bool 2019-08-29 14:28:06 +00:00
roy
93098ee1d3 inet6: change rt_announce and llchange to bool in nd6_na_input() 2019-08-29 14:26:55 +00:00
roy
96c00c9b51 inet6: nd6_free assumes all routers are processed by kernel RA
This hasn't been the case for a long time if you're a dhcpcd
user with a default config. As such, it's possible for the default
IPv6 router as set by dhcpcd could be erroneously gc'ed by nd6_free.

This reduces the scope of the ND6_WLOCK taken as well as fixing an
issue where we write to ln->ln_state without a lock being held.
2019-08-27 21:11:26 +00:00
roy
ece8d0874e nd6: notify userland of neighbour lla updates once more
XXX pullup -8 -9
2019-08-22 21:22:50 +00:00
roy
508a301f81 rtsock: rework rt_clonedmsg to take a message type and lladdr
We will use this in a future patch to notify userland of lladdr
changes.

XXX pullup -8 -9
2019-08-22 21:14:45 +00:00
ozaki-r
bf98d6f362 Add missing IFNET_LOCK for regen_tmpaddr
Reported by ryo@
2019-08-14 08:34:44 +00:00
christos
7e26066147 add forward decl 2019-08-05 10:25:41 +00:00
christos
66f5ac85f3 Decrease the reference count before freeing, so that the entries actually
get free'd. (Ryota Ozaki)
2019-07-26 10:18:42 +00:00
msaitoh
d4a37f7caf Fix typo in comment (s/alreay/already/). 2019-07-24 02:38:29 +00:00
ozaki-r
0ec6d93dcf nd6: restore a missing reachability confirmation
On sending a packet over a STALE cache, the cache should be tried a reachability
confirmation, which is described in RFC 2461/4861 7.3.3.  On the fast path in
nd6_resolve, however, the treatment for STALE caches has been skipped
accidentally.  So STALE caches never be back to the REACHABLE state.

To fix the issue, branch to the fast path only when the cache entry is the
REACHABLE state and leave other caches to the slow path that includes the
treatment.  To this end we need to allow to return a link-layer address if a
valid address is available on the slow path too, which is the same behavior as
FreeBSD and OpenBSD.
2019-06-28 06:45:16 +00:00
rjs
8e33725173 Split out the prototypes for add/delete address into a separate header file. 2019-06-25 15:33:55 +00:00
kamil
5762fe1be2 Decorate struct in6_addr with the __packed attribute
This avoids undefined behavior when accessing misaligned pointers.

Detected by kUBSan.

Patch by Akul Pillai.
2019-05-28 03:56:46 +00:00
ozaki-r
6c6d1e4f71 Get rid of IFNET_LOCK for if_mcast_op to avoid a deadlock
The IFNET_LOCK was added to avoid data races on if_flags for IFF_ALLMULTI.
Unfortunatetly it caused a deadlock instead.  A known scenario causing a
deadlock is to occur the following two operations concurrently: (a) a removal of
an IP adddres assigned to an interface and (b) a manipulation of multicast
groups to the interface.  The resource dependency graph is like this:
  softnet_lock => IFNET_LOCK => psref_target_destroy => softint => softnet_lock

Thanks to the previous commit that avoids data races on if_flags for
IFF_ALLMULTI by another approach, we can remove IFNET_LOCK and defuse the
deadlock.

PR kern/54189
2019-05-15 02:59:18 +00:00
ozaki-r
6d8eb4f9d2 Count packets dropped by pfil 2019-05-13 07:47:59 +00:00
christos
45108122b9 print the name of the interface that was disabled. 2019-05-13 02:03:07 +00:00
roy
2e9156b7e4 Introduce rt_addrmsg_src which adds RTA_AUTHOR to the message.
Use this when we notify userland of a duplicate address
and set RTA_AUTHOR to the hardware address of the sender.

While here, match the logging diagnostic of INET6 to the simpler one
of INET so it's consistent.
2019-04-29 16:12:30 +00:00
roy
4af7afb834 rtsock: Route address message simplification
Rename rt_newaddrmsg to rt_addrmsg_rt.
Add rt_addrmsg which drops the error and route arguments which are only
needed by one caller.
2019-04-29 11:57:22 +00:00
maxv
2d90f583ce Fix small read overflow; harmless, because since I removed RH0, the memory
access on IPV6_RTHDR that would normally be illegal is not needed, and GCC
automatically removes it.
2019-04-03 19:23:38 +00:00
msaitoh
b1b254e088 Fix typos in comment:
- s/paylaod/payload/
- s/dstination/destination/
2019-03-19 13:38:53 +00:00
msaitoh
ad2fa80c12 s/pakcet/packet/ in comment. 2019-03-18 11:38:03 +00:00
maxv
fa4f0f3678 Fix the order in udp6_attach: soreserve should be called before
in6_pcballoc, otherwise if it fails there is still a PCB attached, and
we hit a KASSERT in socreate. In !DIAGNOSTIC this would have caused a
memory leak.

By the way I find the splsoftnet highly suspicious, in6_pcballoc already
does that.

Triggered by SyzKaller.

Reported-by: syzbot+7bace612ca3cc3e124f8@syzkaller.appspotmail.com
2019-02-25 07:31:32 +00:00
maxv
d020c71c0c RIP6, CAN, SCTP and SCTP6 lack a length check in their _send() functions.
Fix RIP6 and CAN, add a big XXX in the SCTP ones.

Found by KASAN, triggered by SyzKaller.

Reported-by: syzbot+0b9692ae0f49f93b7dc7@syzkaller.appspotmail.com
2019-02-25 06:49:44 +00:00
maxv
d26f60da72 RIP, RIP6, DDP, SCTP and SCTP6 lack a length check in their _connect()
functions. Fix the first three, and add a big XXX in the SCTP ones.

Found by KASAN, triggered by SyzKaller.

Reported-by: syzbot+9eaf98dad6ca738c250d@syzkaller.appspotmail.com
2019-02-24 07:20:33 +00:00
mrg
c9d1af0f71 adjust fallthru comments to appease gcc7. 2019-02-05 04:48:47 +00:00
mrg
3035d148fb rework the #ifdef IPSEC code to not use fallthru.
same number of lines with more local context.
2019-02-04 10:48:46 +00:00
martin
dc194ae5f0 Fix memory leaks pointed out by Ilja Van Sprundel: all
sendoob() functions are expted to free both passed
mbuf chains.
2019-01-28 12:53:01 +00:00
knakahara
e2f99c2d1d Fix ipsecif(4) cannot apply input direction packet filter. Reviewed by ozaki-r@n.o and ryo@n.o.
Add ATF later.
2019-01-17 02:47:15 +00:00
maxv
e0e84df697 Fix bug, should be ip6_protox[]. 2019-01-14 18:51:15 +00:00
maxv
b9e11ce70c Remove unused arguments. 2018-12-27 16:59:17 +00:00
maxv
5b040abec8 Replace M_ALIGN and MH_ALIGN by m_align. 2018-12-22 14:28:56 +00:00
maxv
7971121357 Replace: M_COPY_PKTHDR -> m_copy_pkthdr. No functional change, since the
former is a macro to the latter.
2018-12-22 14:07:53 +00:00
maxv
b1305a6d63 Replace: M_MOVE_PKTHDR -> m_move_pkthdr. No functional change, since the
former is a macro to the latter.
2018-12-22 13:11:37 +00:00
roy
4be2a728d1 netinet6: only flush prefixes and routers for the given interface.
Unless it's lo0, where we then flush the lot.
The maintains the status-quo with ndp(8) and allows dhcpcd(8) to at least
try and work with kernel RA on one interface and dhcpcd on another.
2018-12-16 08:54:58 +00:00
roy
f609a819ed inet6: discard any received NA with a LL address we own
This matches ARP behaviour.
2018-12-13 10:27:51 +00:00
rin
7f120f6563 Simplify logic in ip{,6}_output().
Now, we have M_CSUM_TSOv[46] bit in ifp->if_csum_flags_tx when
TSO[46] is enabled for the interface. So we can simply check
whether TSO[46] is required in a packet but missing in the
interface by (sw_csum & M_CSUM_TSOv[46]).

Note that this is a very rare case where TSO[46] is suddenly
turned off during a packet passing b/w TCP and IP.

part of PR kern/53562
OK msaitoh
2018-12-12 01:53:52 +00:00
rin
1cfdd1e3e5 PR kern/53562
Add ether_sw_offload_[tr]x: handle TX/RX offload options in software.
Since this violates separation b/w L2 and L3/L4, new files are added
rather than having the routines in sys/net/if_ethersubr.c.

OK msaitoh thorpej
2018-12-12 01:40:20 +00:00
christos
3b7148fe8e need <sys/endian.h> (or arpa/inet.h) for ntohl() used in macros. 2018-12-10 16:28:52 +00:00
roy
9aebb96254 inet6: match NS nonce to any interface
This allows the same address to exist on many interfaces on the same
prefix, matching the inet behaviour.
2018-12-07 14:47:24 +00:00
roy
1ef19928bd inet6: remove needless ifa_release. 2018-12-04 21:16:54 +00:00
roy
dff9676926 inet6: use one function for nd6_dad_input
Having different ones for NA and NS is a bit wasteful.
2018-12-04 21:01:48 +00:00
roy
7d7b3bbea7 inet6: simplify NA DaD checking 2018-12-04 20:46:56 +00:00
roy
e4ac7437f9 inet6: remove unused dad ns/na counters
The current DaD code triggers when either an NS or NA is directly
received, so the counters themselves do nothing of use.
2018-12-04 12:23:43 +00:00
ozaki-r
74109b2db3 Don't validate the source address of forwarding IPv6 packets (same as IPv4) 2018-11-29 10:02:52 +00:00
ozaki-r
2050bad43a Don't run DAD on link-up if it's explicitly disabled 2018-11-29 09:54:22 +00:00