git: 9312ba239e05 - main - sctp: improve path verification
The branch main has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=9312ba239e05b035c965e5790f70fe71a4ed2e8c commit 9312ba239e05b035c965e5790f70fe71a4ed2e8c Author: Michael Tuexen AuthorDate: 2022-05-14 06:05:03 + Commit: Michael Tuexen CommitDate: 2022-05-14 06:05:03 + sctp: improve path verification When sending path confirmation heartbeats, do not take HB.interval into account when the path is still reachable. Thanks to Alexander Funke for finding the issue and suggesting a fix. MFC after: 3 days --- sys/netinet/sctputil.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/netinet/sctputil.c b/sys/netinet/sctputil.c index 7ac6ce6177d0..1f0b52a205fa 100644 --- a/sys/netinet/sctputil.c +++ b/sys/netinet/sctputil.c @@ -2300,7 +2300,8 @@ sctp_timer_start(int t_type, struct sctp_inpcb *inp, struct sctp_tcb *stcb, } else { to_ticks = UINT32_MAX; } - if (((net->dest_state & SCTP_ADDR_UNCONFIRMED) == 0) && + if (!((net->dest_state & SCTP_ADDR_UNCONFIRMED) && + (net->dest_state & SCTP_ADDR_REACHABLE)) && ((net->dest_state & SCTP_ADDR_PF) == 0)) { if (net->heart_beat_delay < (UINT32_MAX - to_ticks)) { to_ticks += net->heart_beat_delay;
git: aab6e5bd1e2b - main - sctp: improve path verification
The branch main has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=aab6e5bd1e2b2919604eed68f76d4a7bb73ccb0c commit aab6e5bd1e2b2919604eed68f76d4a7bb73ccb0c Author: Michael Tuexen AuthorDate: 2022-05-14 06:07:28 + Commit: Michael Tuexen CommitDate: 2022-05-14 06:07:28 + sctp: improve path verification Ensure that a HB can be sent faster than a HB.Interval when performing path verification of a reachable peer address. Thanks to Alexander Funke for finding the issue and proposing a fix. MFC after: 3 days --- sys/netinet/sctp_timer.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sys/netinet/sctp_timer.c b/sys/netinet/sctp_timer.c index 04c750b990f1..9eff569e0f53 100644 --- a/sys/netinet/sctp_timer.c +++ b/sys/netinet/sctp_timer.c @@ -1439,7 +1439,8 @@ sctp_heartbeat_timer(struct sctp_inpcb *inp, struct sctp_tcb *stcb, (TAILQ_EMPTY(&stcb->asoc.sent_queue))) { sctp_audit_stream_queues_for_size(inp, stcb); } - if (((net->dest_state & SCTP_ADDR_NOHB) == 0) && + if net->dest_state & SCTP_ADDR_NOHB) == 0) || + (net->dest_state & SCTP_ADDR_UNCONFIRMED)) && (net_was_pf || ((net->dest_state & SCTP_ADDR_PF) == 0))) { /* * When moving to PF during threshold management, a HB has @@ -1459,6 +1460,7 @@ sctp_heartbeat_timer(struct sctp_inpcb *inp, struct sctp_tcb *stcb, ms_gone_by = 0x; } if ((ms_gone_by >= net->heart_beat_delay) || + (net->dest_state & SCTP_ADDR_UNCONFIRMED) || (net->dest_state & SCTP_ADDR_PF)) { sctp_send_hb(stcb, net, SCTP_SO_NOT_LOCKED); }
git: f210e4fbc54a - main - sctp: cleanup, no functional change intended
The branch main has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=f210e4fbc54ab78711bd5197b7097002ff3ae891 commit f210e4fbc54ab78711bd5197b7097002ff3ae891 Author: Michael Tuexen AuthorDate: 2022-05-14 06:30:41 + Commit: Michael Tuexen CommitDate: 2022-05-14 06:30:41 + sctp: cleanup, no functional change intended MFC after: 3 days --- sys/netinet/sctp_input.c | 2 +- sys/netinet/sctp_usrreq.c | 8 ++-- sys/netinet/sctputil.c| 2 +- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/sys/netinet/sctp_input.c b/sys/netinet/sctp_input.c index 2823a38a000f..ff16654968d5 100644 --- a/sys/netinet/sctp_input.c +++ b/sys/netinet/sctp_input.c @@ -992,7 +992,7 @@ sctp_handle_shutdown_ack(struct sctp_shutdown_ack_chunk *cp SCTP_UNUSED, if (stcb->sctp_socket) { if ((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) || (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL)) { - stcb->sctp_socket->so_snd.sb_cc = 0; + SCTP_SB_CLEAR(stcb->sctp_socket->so_snd); } sctp_ulp_notify(SCTP_NOTIFY_ASSOC_DOWN, stcb, 0, NULL, SCTP_SO_NOT_LOCKED); } diff --git a/sys/netinet/sctp_usrreq.c b/sys/netinet/sctp_usrreq.c index 02075d79e1aa..98102722c53e 100644 --- a/sys/netinet/sctp_usrreq.c +++ b/sys/netinet/sctp_usrreq.c @@ -846,18 +846,14 @@ sctp_flush(struct socket *so, int how) inp->sctp_flags |= SCTP_PCB_FLAGS_SOCKET_CANT_READ; SCTP_INP_READ_UNLOCK(inp); SCTP_INP_WUNLOCK(inp); - so->so_rcv.sb_cc = 0; - so->so_rcv.sb_mbcnt = 0; - so->so_rcv.sb_mb = NULL; + SCTP_SB_CLEAR(so->so_rcv); } if ((how == PRU_FLUSH_WR) || (how == PRU_FLUSH_RDWR)) { /* * First make sure the sb will be happy, we don't use these * except maybe the count */ - so->so_snd.sb_cc = 0; - so->so_snd.sb_mbcnt = 0; - so->so_snd.sb_mb = NULL; + SCTP_SB_CLEAR(so->so_snd); } return (0); } diff --git a/sys/netinet/sctputil.c b/sys/netinet/sctputil.c index 1f0b52a205fa..8ec934e83cfc 100644 --- a/sys/netinet/sctputil.c +++ b/sys/netinet/sctputil.c @@ -5674,7 +5674,7 @@ restart_nosblocks: #ifdef INVARIANTS panic("Huh, its non zero and nothing on control?"); #endif - so->so_rcv.sb_cc = 0; + SCTP_SB_CLEAR(so->so_rcv); } SCTP_INP_READ_UNLOCK(inp); hold_rlock = 0;
git: c16cbd2e9162 - stable/13 - Default to always accepting the PHY that's present. Linux did something similar a while back, and there are devices in the wild that otherwise won't attach. This patc
The branch stable/13 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=c16cbd2e9162c33e9eee76653dccda7bd6ec2160 commit c16cbd2e9162c33e9eee76653dccda7bd6ec2160 Author: Scott Long AuthorDate: 2022-02-27 01:29:08 + Commit: Alexander Motin CommitDate: 2022-05-15 16:29:57 + Default to always accepting the PHY that's present. Linux did something similar a while back, and there are devices in the wild that otherwise won't attach. This patch is temporary until the PHY code is further cleared up. Obtained from: grehan (cherry picked from commit 6f3c0d2764f230444818a95009028861493c1594) --- sys/dev/igc/igc_i225.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/sys/dev/igc/igc_i225.c b/sys/dev/igc/igc_i225.c index 4c50daa16b79..95d7d1536184 100644 --- a/sys/dev/igc/igc_i225.c +++ b/sys/dev/igc/igc_i225.c @@ -172,14 +172,12 @@ static s32 igc_init_phy_params_i225(struct igc_hw *hw) /* Verify phy id and set remaining function pointers */ switch (phy->id) { case I225_I_PHY_ID: + default: phy->type = igc_phy_i225; phy->ops.set_d0_lplu_state = igc_set_d0_lplu_state_i225; phy->ops.set_d3_lplu_state = igc_set_d3_lplu_state_i225; /* TODO - complete with GPY PHY information */ break; - default: - ret_val = -IGC_ERR_PHY; - goto out; } out:
git: 15adc3b3b4ab - stable/12 - Default to always accepting the PHY that's present. Linux did something similar a while back, and there are devices in the wild that otherwise won't attach. This patc
The branch stable/12 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=15adc3b3b4ab6215e4c9370cf6467a8fac596ecf commit 15adc3b3b4ab6215e4c9370cf6467a8fac596ecf Author: Scott Long AuthorDate: 2022-02-27 01:29:08 + Commit: Alexander Motin CommitDate: 2022-05-15 16:32:26 + Default to always accepting the PHY that's present. Linux did something similar a while back, and there are devices in the wild that otherwise won't attach. This patch is temporary until the PHY code is further cleared up. Obtained from: grehan (cherry picked from commit 6f3c0d2764f230444818a95009028861493c1594) --- sys/dev/igc/igc_i225.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/sys/dev/igc/igc_i225.c b/sys/dev/igc/igc_i225.c index 4c50daa16b79..95d7d1536184 100644 --- a/sys/dev/igc/igc_i225.c +++ b/sys/dev/igc/igc_i225.c @@ -172,14 +172,12 @@ static s32 igc_init_phy_params_i225(struct igc_hw *hw) /* Verify phy id and set remaining function pointers */ switch (phy->id) { case I225_I_PHY_ID: + default: phy->type = igc_phy_i225; phy->ops.set_d0_lplu_state = igc_set_d0_lplu_state_i225; phy->ops.set_d3_lplu_state = igc_set_d3_lplu_state_i225; /* TODO - complete with GPY PHY information */ break; - default: - ret_val = -IGC_ERR_PHY; - goto out; } out:
git: 3f8306cf8e2d - stable/13 - e1000: Increase rx_buffer_size to 32b
The branch stable/13 has been updated by kbowling (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=3f8306cf8e2d817f3c50ec2ecdfa52a71f2515ae commit 3f8306cf8e2d817f3c50ec2ecdfa52a71f2515ae Author: Kevin Bowling AuthorDate: 2022-05-12 15:38:09 + Commit: Kevin Bowling CommitDate: 2022-05-15 17:04:00 + e1000: Increase rx_buffer_size to 32b Extend the size of the local rx_buffer_size variable to account for larger buffer sizes possible on 82580, i350 chips. From i350 datasheet, 6.2.10 Initialization Control 4 (LAN Base Address + Offset 0x13): When 4 ports are enabled maximum buffer size is 36 KB. When 2 ports are enabled maximum buffer size is 72 KB. When only a single port is enabled maximum buffer size is 144 KB. and 8.3: The overall available internal buffer size in the I350 for all ports is 144 KB for receive buffers and 80 KB for transmit Buffers. Disabled ports memory can be shared between active ports and sharing can be asymmetric. The default buffer size for each port is loaded from the EEPROM on initialization. From the reporter: But for I350 when only 2 ports are used PBA size can be set as 72KB (see datasheet RXPbsize or e1000_rxpbs_adjust_82580 function in e1000_82575.c). In this case calculating the rx_buffer_size overflows as 0x0048 << 10 = 73728 or 0x12000 pushed into u16. It is then set as 0x2000 or 8192. PR: 263896 Reported by:hann...@gmail.com Tested by: hann...@gmail.com Approved by:markj Differential Revision: https://reviews.freebsd.org/D35167 (cherry picked from commit 6987c47569b377f4b6eba9966afdedfb1b39fca8) --- sys/dev/e1000/if_em.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/dev/e1000/if_em.c b/sys/dev/e1000/if_em.c index f9d3edbd59a6..6dd494f1fbb3 100644 --- a/sys/dev/e1000/if_em.c +++ b/sys/dev/e1000/if_em.c @@ -2479,7 +2479,7 @@ em_reset(if_ctx_t ctx) struct e1000_softc *sc = iflib_get_softc(ctx); struct ifnet *ifp = iflib_get_ifp(ctx); struct e1000_hw *hw = &sc->hw; - u16 rx_buffer_size; + u32 rx_buffer_size; u32 pba; INIT_DEBUGOUT("em_reset: begin");
git: f4262a065dcf - stable/12 - e1000: Increase rx_buffer_size to 32b
The branch stable/12 has been updated by kbowling (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=f4262a065dcf32169d2e8b5434a5030bf60f1ae3 commit f4262a065dcf32169d2e8b5434a5030bf60f1ae3 Author: Kevin Bowling AuthorDate: 2022-05-12 15:38:09 + Commit: Kevin Bowling CommitDate: 2022-05-15 17:04:38 + e1000: Increase rx_buffer_size to 32b Extend the size of the local rx_buffer_size variable to account for larger buffer sizes possible on 82580, i350 chips. From i350 datasheet, 6.2.10 Initialization Control 4 (LAN Base Address + Offset 0x13): When 4 ports are enabled maximum buffer size is 36 KB. When 2 ports are enabled maximum buffer size is 72 KB. When only a single port is enabled maximum buffer size is 144 KB. and 8.3: The overall available internal buffer size in the I350 for all ports is 144 KB for receive buffers and 80 KB for transmit Buffers. Disabled ports memory can be shared between active ports and sharing can be asymmetric. The default buffer size for each port is loaded from the EEPROM on initialization. From the reporter: But for I350 when only 2 ports are used PBA size can be set as 72KB (see datasheet RXPbsize or e1000_rxpbs_adjust_82580 function in e1000_82575.c). In this case calculating the rx_buffer_size overflows as 0x0048 << 10 = 73728 or 0x12000 pushed into u16. It is then set as 0x2000 or 8192. PR: 263896 Reported by:hann...@gmail.com Tested by: hann...@gmail.com Approved by:markj Differential Revision: https://reviews.freebsd.org/D35167 (cherry picked from commit 6987c47569b377f4b6eba9966afdedfb1b39fca8) --- sys/dev/e1000/if_em.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/dev/e1000/if_em.c b/sys/dev/e1000/if_em.c index 7e854514aafb..821bb87f0ff3 100644 --- a/sys/dev/e1000/if_em.c +++ b/sys/dev/e1000/if_em.c @@ -2467,7 +2467,7 @@ em_reset(if_ctx_t ctx) struct e1000_softc *sc = iflib_get_softc(ctx); struct ifnet *ifp = iflib_get_ifp(ctx); struct e1000_hw *hw = &sc->hw; - u16 rx_buffer_size; + u32 rx_buffer_size; u32 pba; INIT_DEBUGOUT("em_reset: begin");
git: 3bae1cd68a2a - main - linux(4): Implement futex_op for arm64.
The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=3bae1cd68a2ac3e2c37d54cf550e01257dfb1a04 commit 3bae1cd68a2ac3e2c37d54cf550e01257dfb1a04 Author: Dmitry Chagin AuthorDate: 2022-05-15 17:49:42 + Commit: Dmitry Chagin CommitDate: 2022-05-15 17:49:42 + linux(4): Implement futex_op for arm64. It's mostly modeled like the Linux does. Differential revision: https://reviews.freebsd.org/D35154 MFC after: 2 weeks --- sys/arm64/linux/linux_support.s | 130 +--- 1 file changed, 123 insertions(+), 7 deletions(-) diff --git a/sys/arm64/linux/linux_support.s b/sys/arm64/linux/linux_support.s index 1048e9579627..933930b5096f 100644 --- a/sys/arm64/linux/linux_support.s +++ b/sys/arm64/linux/linux_support.s @@ -2,6 +2,7 @@ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD * * Copyright (C) 2018 Turing Robotic Industries Inc. + * Copyright (C) 2022 Dmitry Chagin * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -27,36 +28,151 @@ * $FreeBSD$ */ -#include "linux_assym.h" #include +__FBSDID("$FreeBSD$"); + +#include +#include + +#include #include "assym.inc" +.macro check_user_access user_arg, limit, bad_addr_func + ldr x7, =(\limit) + cmp x\user_arg, x7 + b.cs\bad_addr_func +.endm + +futex_fault: + SET_FAULT_HANDLER(xzr, x1) + EXIT_USER_ACCESS_CHECK(w0, x1) +futex_fault_nopcb: + mov x0, #EFAULT + ret + +#defineLINUX_FUTEX_MAX_LOOPS 128 + /* - * LINUXTODO: implement futex_* + * int oparg, uint32_t *uaddr, int *oldval + * + * Return 0 on success, errno on failure, + * EAGAIN is returned if LL/SC operation fails. + * + * XXX. VM_MAXUSER_ADDRESS is not applicable here, should be replaced + * by something like LINUX_SHAREDPAGE. */ +/* (int *)uaddr2 = oparg */ ENTRY(futex_xchgl) - brk #0 + check_user_access 1, (VM_MAXUSER_ADDRESS-3), futex_fault_nopcb + adr x9, futex_fault /* Load the fault handler */ + SET_FAULT_HANDLER(x9, x4) /* And set it */ + ENTER_USER_ACCESS(w9, x4) + mov w5, #LINUX_FUTEX_MAX_LOOPS + prfmpstl1strm, [x1] + mov w6, w0 /* Save oparg */ +1: ldxrw4, [x1]/* Load oldval from uaddr */ + stlxr w0, w6, [x1]/* Store oparg to uaddr */ + cbz w0, 3f /* Exit on success */ + sub w5, w5, w0 /* Dec loop counter, w0 is 1 */ + cbnzw5, 1b /* Loop */ + mov x0, #EAGAIN /* Store of newval failed */ +3: dmb ish + EXIT_USER_ACCESS(w9) + SET_FAULT_HANDLER(xzr, x9) /* Reset the fault handler */ + str w4, [x2]/* Store oldval */ ret END(futex_xchgl) +/* (int *)uaddr2 += oparg */ ENTRY(futex_addl) - brk #0 + check_user_access 1, (VM_MAXUSER_ADDRESS-3), futex_fault_nopcb + adr x9, futex_fault + SET_FAULT_HANDLER(x9, x4) + ENTER_USER_ACCESS(w9, x4) + mov w5, #LINUX_FUTEX_MAX_LOOPS + prfmpstl1strm, [x1] + mov w6, w0 +1: ldxrw4, [x1] + add w3, w4, w6 /* oldval + oparg */ + stlxr w0, w3, [x1] + cbz w0, 3f + sub w5, w5, w0 + cbnzw5, 1b + mov x0, #EAGAIN +3: dmb ish + EXIT_USER_ACCESS(w9) + SET_FAULT_HANDLER(xzr, x9) + str w4, [x2] ret END(futex_addl) +/* (int *)uaddr2 |= oparg */ ENTRY(futex_orl) - brk #0 + check_user_access 1, (VM_MAXUSER_ADDRESS-3), futex_fault_nopcb + adr x9, futex_fault + SET_FAULT_HANDLER(x9, x4) + ENTER_USER_ACCESS(w9, x4) + mov w5, #LINUX_FUTEX_MAX_LOOPS + prfmpstl1strm, [x1] + mov w6, w0 +1: ldxrw4, [x1] + orr w3, w4, w6 /* oldavl |= oparg */ + stlxr w0, w3, [x1] + cbz w0, 3f + sub w5, w5, w0 + cbnzw5, 1b + mov x0, #EAGAIN +3: dmb ish + EXIT_USER_ACCESS(w9) + SET_FAULT_HANDLER(xzr, x9) + str w4, [x2] ret END(futex_orl) +/* (int *)uaddr2 &= oparg */ ENTRY(futex_andl) - brk #0 + check_user_access 1, (VM_MAXUSER_ADDRESS-3), futex_fault_nopcb + adr x9, futex_fault + SET_FAULT_HANDLER(x9, x4) + ENTER_USER_ACCESS(w9, x4) + mov w5, #LINUX_FUTEX_MAX_LOOPS + prfmpstl1strm, [x1] + mov w6, w0 +1: ldxrw4, [x1] + and w3, w4, w6 /* oldval &= oparg */ + stlxr w0, w3, [x1] + cbz w0, 3f + sub w5, w5, w0 + cbnzw5, 1b + mov x0, #EAGAIN +3: dmb ish + EXIT_USER_ACCESS(w9) + SET_FAULT_HANDLER(xzr, x9)
git: 0b5d5dc3767f - main - linux(4): Retire unneeded initialization
The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=0b5d5dc3767fcf2f0198f0f9549cb23983e0ee3e commit 0b5d5dc3767fcf2f0198f0f9549cb23983e0ee3e Author: Dmitry Chagin AuthorDate: 2022-05-15 17:58:47 + Commit: Dmitry Chagin CommitDate: 2022-05-15 17:58:47 + linux(4): Retire unneeded initialization Both uc_flags and uc_link are zeroed above. On amd64 and i386 the uc_link field is not used at all. The UC_FP_XSTATE bit should be set in the uc_flags if OS xsave knob is turned on (and xsave is implemented). MFC after: 2 weeks --- sys/amd64/linux32/linux32_sysvec.c | 3 --- sys/i386/linux/linux_sysvec.c | 3 --- 2 files changed, 6 deletions(-) diff --git a/sys/amd64/linux32/linux32_sysvec.c b/sys/amd64/linux32/linux32_sysvec.c index b57d6f93d94b..ed430c8e579a 100644 --- a/sys/amd64/linux32/linux32_sysvec.c +++ b/sys/amd64/linux32/linux32_sysvec.c @@ -325,9 +325,6 @@ linux_rt_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask) /* * Build the signal context to be used by sigreturn and libgcc unwind. */ - frame.sf_sc.uc_flags = 0; /* XXX ??? */ - frame.sf_sc.uc_link = 0;/* XXX ??? */ - frame.sf_sc.uc_stack.ss_sp = PTROUT(td->td_sigstk.ss_sp); frame.sf_sc.uc_stack.ss_size = td->td_sigstk.ss_size; frame.sf_sc.uc_stack.ss_flags = (td->td_pflags & TDP_ALTSTACK) diff --git a/sys/i386/linux/linux_sysvec.c b/sys/i386/linux/linux_sysvec.c index 53e7e6f7..9f0647f73c0c 100644 --- a/sys/i386/linux/linux_sysvec.c +++ b/sys/i386/linux/linux_sysvec.c @@ -431,9 +431,6 @@ linux_rt_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask) siginfo_to_lsiginfo(&ksi->ksi_info, &frame.sf_si, sig); /* Build the signal context to be used by sigreturn. */ - frame.sf_sc.uc_flags = 0; /* XXX ??? */ - frame.sf_sc.uc_link = NULL; /* XXX ??? */ - frame.sf_sc.uc_stack.ss_sp = PTROUT(td->td_sigstk.ss_sp); frame.sf_sc.uc_stack.ss_size = td->td_sigstk.ss_size; frame.sf_sc.uc_stack.ss_flags = (td->td_pflags & TDP_ALTSTACK)
git: ba279bcd6d75 - main - linux(4): Cleanup signal trampolines
The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=ba279bcd6d75aa236bcb9ccf11aeb6f51a2f8514 commit ba279bcd6d75aa236bcb9ccf11aeb6f51a2f8514 Author: Dmitry Chagin AuthorDate: 2022-05-15 18:00:05 + Commit: Dmitry Chagin CommitDate: 2022-05-15 18:00:05 + linux(4): Cleanup signal trampolines This is the first stage of a signal trampolines refactoring. From trampolines retired emulation of the 'call' instruction, which is replaced by direct call of a signal handler. The signal handler address is in the register. The previous trampoline implemenatation used semi-Linux-way to call a signal handler via the 'jmp' instruction. Wherefore the trampoline emulated a 'call' instruction to into the stack the return address for signal handler's 'ret' instruction. Wherefore handmade DWARD annotations was used. While here rephrased and removed excessive comments. MFC after: 2 weeks --- sys/amd64/linux/linux.h | 1 - sys/amd64/linux/linux_genassym.c | 1 - sys/amd64/linux/linux_locore.asm | 19 +-- sys/amd64/linux/linux_sysvec.c | 2 +- sys/amd64/linux32/linux.h| 4 sys/amd64/linux32/linux32_genassym.c | 2 -- sys/amd64/linux32/linux32_locore.asm | 34 +- sys/amd64/linux32/linux32_sysvec.c | 4 ++-- sys/i386/linux/linux.h | 4 sys/i386/linux/linux_genassym.c | 2 -- sys/i386/linux/linux_locore.asm | 32 sys/i386/linux/linux_sysvec.c| 4 ++-- 12 files changed, 27 insertions(+), 82 deletions(-) diff --git a/sys/amd64/linux/linux.h b/sys/amd64/linux/linux.h index 920ca98ce01b..08cf3d4b6bbd 100644 --- a/sys/amd64/linux/linux.h +++ b/sys/amd64/linux/linux.h @@ -314,7 +314,6 @@ typedef struct l_siginfo { struct l_rt_sigframe { struct l_ucontext sf_sc; struct l_siginfosf_si; - l_handler_t sf_handler; }; /* diff --git a/sys/amd64/linux/linux_genassym.c b/sys/amd64/linux/linux_genassym.c index 0edb6a043531..73febbe6ef40 100644 --- a/sys/amd64/linux/linux_genassym.c +++ b/sys/amd64/linux/linux_genassym.c @@ -8,7 +8,6 @@ __FBSDID("$FreeBSD$"); #include #include -ASSYM(LINUX_RT_SIGF_HANDLER, offsetof(struct l_rt_sigframe, sf_handler)); ASSYM(LINUX_RT_SIGF_UC, offsetof(struct l_rt_sigframe, sf_sc)); ASSYM(LINUX_RT_SIGF_SC, offsetof(struct l_ucontext, uc_mcontext)); ASSYM(LINUX_VERSION_CODE, LINUX_VERSION_CODE); diff --git a/sys/amd64/linux/linux_locore.asm b/sys/amd64/linux/linux_locore.asm index dd482cb87cc8..8b6833d7352f 100644 --- a/sys/amd64/linux/linux_locore.asm +++ b/sys/amd64/linux/linux_locore.asm @@ -11,23 +11,14 @@ linux_platform: .asciz "x86_64" - .text -/* - * To avoid excess stack frame the signal trampoline code emulates - * the 'call' instruction. - */ + ENTRY(linux_rt_sigcode) - movq%rsp, %rbx /* preserve sigframe */ - call.getip -.getip: - popq%rax - add $.startrtsigcode-.getip, %rax /* ret address */ - pushq %rax - jmp *LINUX_RT_SIGF_HANDLER(%rbx) + movq%rsp, %rbx /* rt_sigframe for rt_sigreturn */ + call*%rcx /* call signal handler */ .startrtsigcode: - movq$LINUX_SYS_linux_rt_sigreturn,%rax /* linux_rt_sigreturn() */ - syscall /* enter kernel with args */ + movq$LINUX_SYS_linux_rt_sigreturn, %rax + syscall hlt .endrtsigcode: 0: jmp 0b diff --git a/sys/amd64/linux/linux_sysvec.c b/sys/amd64/linux/linux_sysvec.c index 1ea274da8935..ea91dcae5d49 100644 --- a/sys/amd64/linux/linux_sysvec.c +++ b/sys/amd64/linux/linux_sysvec.c @@ -686,10 +686,10 @@ linux_rt_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask) regs->tf_rax = 0; regs->tf_rsi = (register_t)&sfp->sf_si; /* arg 2 in %rsi */ regs->tf_rdx = (register_t)&sfp->sf_sc; /* arg 3 in %rdx */ + regs->tf_rcx = (register_t)catcher; /* Fill in POSIX parts. */ siginfo_to_lsiginfo(&ksi->ksi_info, &sf.sf_si, sig); - sf.sf_handler = catcher; mtx_unlock(&psp->ps_mtx); PROC_UNLOCK(p); diff --git a/sys/amd64/linux32/linux.h b/sys/amd64/linux32/linux.h index 1273ff485dd9..ba7aeac517e1 100644 --- a/sys/amd64/linux32/linux.h +++ b/sys/amd64/linux32/linux.h @@ -429,15 +429,12 @@ struct l_fpstate { /* * We make the stack look like Linux expects it when calling a signal * handler, but use the BSD way of calling the handler and sigreturn(). - * This means that we need to pass the pointer to the handler too. - * It is appended to the frame to not interfere with the rest of it. */ struct l_sigframe { l_int sf_sig; struct l_sigcontext sf_sc;
git: 21f246174184 - main - linux(4): Move sigframe definitions to separate headers
The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=21f246174184742ba8952aeb1dadbf58d48d54b4 commit 21f246174184742ba8952aeb1dadbf58d48d54b4 Author: Dmitry Chagin AuthorDate: 2022-05-15 18:03:01 + Commit: Dmitry Chagin CommitDate: 2022-05-15 18:03:01 + linux(4): Move sigframe definitions to separate headers The signal trampoine-related definitions are used only in the MD part of code, wherefore moved from everywhere used linux.h to separate MD headers. MFC after: 2 weeks --- sys/amd64/linux/linux.h | 65 sys/amd64/linux/linux_genassym.c | 2 + sys/amd64/linux/linux_sysvec.c | 2 + sys/amd64/linux32/linux.h| 90 sys/amd64/linux32/linux32_genassym.c | 2 + sys/amd64/linux32/linux32_sysvec.c | 2 + sys/arm64/linux/linux.h | 10 -- sys/arm64/linux/linux_sigframe.h | 44 sys/arm64/linux/linux_sysvec.c | 2 + sys/i386/linux/linux.h | 92 sys/i386/linux/linux_genassym.c | 2 + sys/i386/linux/linux_sysvec.c| 14 +-- sys/x86/linux/linux_x86_sigframe.h | 196 +++ 13 files changed, 260 insertions(+), 263 deletions(-) diff --git a/sys/amd64/linux/linux.h b/sys/amd64/linux/linux.h index 08cf3d4b6bbd..51a2906f45cf 100644 --- a/sys/amd64/linux/linux.h +++ b/sys/amd64/linux/linux.h @@ -182,59 +182,6 @@ typedef struct { l_size_tss_size; } l_stack_t; -struct l_fpstate { - u_int16_t cwd; - u_int16_t swd; - u_int16_t twd; - u_int16_t fop; - u_int64_t rip; - u_int64_t rdp; - u_int32_t mxcsr; - u_int32_t mxcsr_mask; - u_int32_t st_space[32]; - u_int32_t xmm_space[64]; - u_int32_t reserved2[24]; -}; - -struct l_sigcontext { - l_ulong sc_r8; - l_ulong sc_r9; - l_ulong sc_r10; - l_ulong sc_r11; - l_ulong sc_r12; - l_ulong sc_r13; - l_ulong sc_r14; - l_ulong sc_r15; - l_ulong sc_rdi; - l_ulong sc_rsi; - l_ulong sc_rbp; - l_ulong sc_rbx; - l_ulong sc_rdx; - l_ulong sc_rax; - l_ulong sc_rcx; - l_ulong sc_rsp; - l_ulong sc_rip; - l_ulong sc_rflags; - l_ushortsc_cs; - l_ushortsc_gs; - l_ushortsc_fs; - l_ushortsc___pad0; - l_ulong sc_err; - l_ulong sc_trapno; - l_sigset_t sc_mask; - l_ulong sc_cr2; - struct l_fpstate *sc_fpstate; - l_ulong sc_reserved1[8]; -}; - -struct l_ucontext { - l_ulong uc_flags; - l_uintptr_t uc_link; - l_stack_t uc_stack; - struct l_sigcontext uc_mcontext; - l_sigset_t uc_sigmask; -}; - #define LINUX_SI_PREAMBLE_SIZE (4 * sizeof(int)) #defineLINUX_SI_MAX_SIZE 128 #defineLINUX_SI_PAD_SIZE ((LINUX_SI_MAX_SIZE - \ @@ -304,18 +251,6 @@ typedef struct l_siginfo { #definelsi_band_sifields._sigpoll._band #definelsi_fd _sifields._sigpoll._fd -/* - * We make the stack look like Linux expects it when calling a signal - * handler, but use the BSD way of calling the handler and sigreturn(). - * This means that we need to pass the pointer to the handler too. - * It is appended to the frame to not interfere with the rest of it. - */ - -struct l_rt_sigframe { - struct l_ucontext sf_sc; - struct l_siginfosf_si; -}; - /* * mount flags */ diff --git a/sys/amd64/linux/linux_genassym.c b/sys/amd64/linux/linux_genassym.c index 73febbe6ef40..a468520431dc 100644 --- a/sys/amd64/linux/linux_genassym.c +++ b/sys/amd64/linux/linux_genassym.c @@ -8,6 +8,8 @@ __FBSDID("$FreeBSD$"); #include #include +#include + ASSYM(LINUX_RT_SIGF_UC, offsetof(struct l_rt_sigframe, sf_sc)); ASSYM(LINUX_RT_SIGF_SC, offsetof(struct l_ucontext, uc_mcontext)); ASSYM(LINUX_VERSION_CODE, LINUX_VERSION_CODE); diff --git a/sys/amd64/linux/linux_sysvec.c b/sys/amd64/linux/linux_sysvec.c index ea91dcae5d49..58ab443cd8b1 100644 --- a/sys/amd64/linux/linux_sysvec.c +++ b/sys/amd64/linux/linux_sysvec.c @@ -86,6 +86,8 @@ __FBSDID("$FreeBSD$"); #include #include +#include + MODULE_VERSION(linux64, 1); #defineLINUX_VDSOPAGE_SIZE PAGE_SIZE * 2 diff --git a/sys/amd64/linux32/linux.h b/sys/amd64/linux32/linux.h index ba7aeac517e1..1987ff515275 100644 --- a/sys/amd64/linux32/linux.h +++ b/sys/amd64/linux32/linux.h @@ -287,40 +287,6 @@ typedef struct { l_size_tss_size; } l_stack_t; -/* The Linux sigcontext, pretty much a standard 386 trapframe. */ -struct l_sigcontext { - l_uint sc_gs; - l_uint
git: af557e649cf2 - main - linux(4): Rework the definition of struct siginfo to match Linux actual one
The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=af557e649cf229e45a83767c3c4a7daeb92f0b01 commit af557e649cf229e45a83767c3c4a7daeb92f0b01 Author: Dmitry Chagin AuthorDate: 2022-05-15 18:05:01 + Commit: Dmitry Chagin CommitDate: 2022-05-15 18:05:01 + linux(4): Rework the definition of struct siginfo to match Linux actual one Rework the defintion of struct siginfo so that the array padding struct siginfo to SI_MAX_SIZE can be placed in a union along side of the rest of the struct siginfo members. The result is that we no longer need the __ARCH_SI_PREAMBLE_SIZE or SI_PAD_SIZE definitions. Move struct siginfo definition under /compat/linux to reduce MD part. To avoid headers polution include linux_siginfo.h in the MD linux.h MFC after: 2 weeks --- sys/amd64/linux/linux.h | 71 +--- sys/amd64/linux32/linux.h| 70 +--- sys/arm64/linux/linux.h | 71 +--- sys/compat/linux/linux_siginfo.h | 113 +++ sys/i386/linux/linux.h | 70 +--- 5 files changed, 121 insertions(+), 274 deletions(-) diff --git a/sys/amd64/linux/linux.h b/sys/amd64/linux/linux.h index 51a2906f45cf..02aede96ce23 100644 --- a/sys/amd64/linux/linux.h +++ b/sys/amd64/linux/linux.h @@ -74,6 +74,8 @@ typedef l_int l_mqd_t; typedef l_size_t l_socklen_t; typedefl_ulong l_fd_mask; +#include + typedef struct { l_int val[2]; } l_fsid_t; @@ -182,75 +184,6 @@ typedef struct { l_size_tss_size; } l_stack_t; -#define LINUX_SI_PREAMBLE_SIZE (4 * sizeof(int)) -#defineLINUX_SI_MAX_SIZE 128 -#defineLINUX_SI_PAD_SIZE ((LINUX_SI_MAX_SIZE - \ - LINUX_SI_PREAMBLE_SIZE) / sizeof(l_int)) -typedef union l_sigval { - l_int sival_int; - l_uintptr_t sival_ptr; -} l_sigval_t; - -typedef struct l_siginfo { - l_int lsi_signo; - l_int lsi_errno; - l_int lsi_code; - union { - l_int _pad[LINUX_SI_PAD_SIZE]; - - struct { - l_pid_t _pid; - l_uid_t _uid; - } _kill; - - struct { - l_timer_t _tid; - l_int _overrun; - char_pad[sizeof(l_uid_t) - sizeof(int)]; - union l_sigval _sigval; - l_uint _sys_private; - } _timer; - - struct { - l_pid_t _pid; /* sender's pid */ - l_uid_t _uid; /* sender's uid */ - union l_sigval _sigval; - } _rt; - - struct { - l_pid_t _pid; /* which child */ - l_uid_t _uid; /* sender's uid */ - l_int _status;/* exit code */ - l_clock_t _utime; - l_clock_t _stime; - } _sigchld; - - struct { - l_uintptr_t _addr; /* Faulting insn/memory ref. */ - } _sigfault; - - struct { - l_long _band; /* POLL_IN,POLL_OUT,POLL_MSG */ - l_int _fd; - } _sigpoll; - } _sifields; -} l_siginfo_t; - -#definelsi_pid _sifields._kill._pid -#definelsi_uid _sifields._kill._uid -#definelsi_tid _sifields._timer._tid -#definelsi_overrun _sifields._timer._overrun -#definelsi_sys_private _sifields._timer._sys_private -#definelsi_status _sifields._sigchld._status -#definelsi_utime _sifields._sigchld._utime -#definelsi_stime _sifields._sigchld._stime -#definelsi_value _sifields._rt._sigval -#definelsi_int _sifields._rt._sigval.sival_int -#definelsi_ptr _sifields._rt._sigval.sival_ptr -#definelsi_addr_sifields._sigfault._addr -#definelsi_band_sifields._sigpoll._band -#definelsi_fd _sifields._sigpoll._fd - /* * mount flags */ diff --git a/sys/amd64/linux32/linux.h b/sys/amd64/linux32/linux.h index 1987ff515275..5cdf7624fef5 100644 --- a/sys/amd64/linux32/linux.h +++ b/sys/amd64/linux32/linux.h @@ -82,6 +82,8 @@ typedef l_int l_timer_t; typedef l_int l_mqd_t; typedefl_ulong l_fd_mask; +#include + typedef struct { l_int val[2]; } l_fsid_t; @@ -287,74 +289,6 @@ typedef struct { l_size_tss_
git: 6e826d27c340 - main - linux(4): Better naming for ucontext field of struct rt_sigframe
The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=6e826d27c340fa29e166d06e5d8553f6c63c409e commit 6e826d27c340fa29e166d06e5d8553f6c63c409e Author: Dmitry Chagin AuthorDate: 2022-05-15 18:06:47 + Commit: Dmitry Chagin CommitDate: 2022-05-15 18:06:47 + linux(4): Better naming for ucontext field of struct rt_sigframe To reduce sendsig code difference and to avoid confusing me, rename sf_sc to sf_uc to match the content. MFC after: 2 weeks --- sys/amd64/linux/linux_genassym.c | 2 +- sys/amd64/linux/linux_sysvec.c | 56 ++-- sys/amd64/linux32/linux32_genassym.c | 2 +- sys/amd64/linux32/linux32_sysvec.c | 54 +- sys/i386/linux/linux_genassym.c | 2 +- sys/i386/linux/linux_sysvec.c| 54 +- sys/x86/linux/linux_x86_sigframe.h | 4 +-- 7 files changed, 87 insertions(+), 87 deletions(-) diff --git a/sys/amd64/linux/linux_genassym.c b/sys/amd64/linux/linux_genassym.c index a468520431dc..a9658b006be8 100644 --- a/sys/amd64/linux/linux_genassym.c +++ b/sys/amd64/linux/linux_genassym.c @@ -10,7 +10,7 @@ __FBSDID("$FreeBSD$"); #include -ASSYM(LINUX_RT_SIGF_UC, offsetof(struct l_rt_sigframe, sf_sc)); +ASSYM(LINUX_RT_SIGF_UC, offsetof(struct l_rt_sigframe, sf_uc)); ASSYM(LINUX_RT_SIGF_SC, offsetof(struct l_ucontext, uc_mcontext)); ASSYM(LINUX_VERSION_CODE, LINUX_VERSION_CODE); ASSYM(LINUX_SC_RSP, offsetof(struct l_sigcontext, sc_rsp)); diff --git a/sys/amd64/linux/linux_sysvec.c b/sys/amd64/linux/linux_sysvec.c index 58ab443cd8b1..fe7796179e4b 100644 --- a/sys/amd64/linux/linux_sysvec.c +++ b/sys/amd64/linux/linux_sysvec.c @@ -639,36 +639,36 @@ linux_rt_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask) /* Save user context. */ bzero(&sf, sizeof(sf)); - bsd_to_linux_sigset(mask, &sf.sf_sc.uc_sigmask); - bsd_to_linux_sigset(mask, &sf.sf_sc.uc_mcontext.sc_mask); + bsd_to_linux_sigset(mask, &sf.sf_uc.uc_sigmask); + bsd_to_linux_sigset(mask, &sf.sf_uc.uc_mcontext.sc_mask); - sf.sf_sc.uc_stack.ss_sp = PTROUT(td->td_sigstk.ss_sp); - sf.sf_sc.uc_stack.ss_size = td->td_sigstk.ss_size; - sf.sf_sc.uc_stack.ss_flags = (td->td_pflags & TDP_ALTSTACK) + sf.sf_uc.uc_stack.ss_sp = PTROUT(td->td_sigstk.ss_sp); + sf.sf_uc.uc_stack.ss_size = td->td_sigstk.ss_size; + sf.sf_uc.uc_stack.ss_flags = (td->td_pflags & TDP_ALTSTACK) ? ((oonstack) ? LINUX_SS_ONSTACK : 0) : LINUX_SS_DISABLE; - sf.sf_sc.uc_mcontext.sc_rdi= regs->tf_rdi; - sf.sf_sc.uc_mcontext.sc_rsi= regs->tf_rsi; - sf.sf_sc.uc_mcontext.sc_rdx= regs->tf_rdx; - sf.sf_sc.uc_mcontext.sc_rbp= regs->tf_rbp; - sf.sf_sc.uc_mcontext.sc_rbx= regs->tf_rbx; - sf.sf_sc.uc_mcontext.sc_rcx= regs->tf_rcx; - sf.sf_sc.uc_mcontext.sc_rax= regs->tf_rax; - sf.sf_sc.uc_mcontext.sc_rip= regs->tf_rip; - sf.sf_sc.uc_mcontext.sc_rsp= regs->tf_rsp; - sf.sf_sc.uc_mcontext.sc_r8 = regs->tf_r8; - sf.sf_sc.uc_mcontext.sc_r9 = regs->tf_r9; - sf.sf_sc.uc_mcontext.sc_r10= regs->tf_r10; - sf.sf_sc.uc_mcontext.sc_r11= regs->tf_r11; - sf.sf_sc.uc_mcontext.sc_r12= regs->tf_r12; - sf.sf_sc.uc_mcontext.sc_r13= regs->tf_r13; - sf.sf_sc.uc_mcontext.sc_r14= regs->tf_r14; - sf.sf_sc.uc_mcontext.sc_r15= regs->tf_r15; - sf.sf_sc.uc_mcontext.sc_cs = regs->tf_cs; - sf.sf_sc.uc_mcontext.sc_rflags = regs->tf_rflags; - sf.sf_sc.uc_mcontext.sc_err= regs->tf_err; - sf.sf_sc.uc_mcontext.sc_trapno = bsd_to_linux_trapcode(code); - sf.sf_sc.uc_mcontext.sc_cr2= (register_t)ksi->ksi_addr; + sf.sf_uc.uc_mcontext.sc_rdi= regs->tf_rdi; + sf.sf_uc.uc_mcontext.sc_rsi= regs->tf_rsi; + sf.sf_uc.uc_mcontext.sc_rdx= regs->tf_rdx; + sf.sf_uc.uc_mcontext.sc_rbp= regs->tf_rbp; + sf.sf_uc.uc_mcontext.sc_rbx= regs->tf_rbx; + sf.sf_uc.uc_mcontext.sc_rcx= regs->tf_rcx; + sf.sf_uc.uc_mcontext.sc_rax= regs->tf_rax; + sf.sf_uc.uc_mcontext.sc_rip= regs->tf_rip; + sf.sf_uc.uc_mcontext.sc_rsp= regs->tf_rsp; + sf.sf_uc.uc_mcontext.sc_r8 = regs->tf_r8; + sf.sf_uc.uc_mcontext.sc_r9 = regs->tf_r9; + sf.sf_uc.uc_mcontext.sc_r10= regs->tf_r10; + sf.sf_uc.uc_mcontext.sc_r11= regs->tf_r11; + sf.sf_uc.uc_mcontext.sc_r12= regs->tf_r12; + sf.sf_uc.uc_mcontext.sc_r13= regs->tf_r13; + sf.sf_uc.uc_mcontext.sc_r14= regs->tf_r14; + sf.sf_uc.uc_mcontext.sc_r15= regs->tf_r15; + sf.sf_uc.uc_mcontext.sc_cs = regs->tf_cs; + sf.sf_uc.uc_mcontext.sc_rflags = regs->tf_rflags; + sf.sf_uc.uc_mcontext.sc_err= regs->tf_err; + sf.sf_uc.uc_mcontext.sc_tr
git: 08e201a3b462 - main - linux(4): Retire unused include
The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=08e201a3b4624d84f67f4587ab21b4b4abf61e76 commit 08e201a3b4624d84f67f4587ab21b4b4abf61e76 Author: Dmitry Chagin AuthorDate: 2022-05-15 18:08:45 + Commit: Dmitry Chagin CommitDate: 2022-05-15 18:08:45 + linux(4): Retire unused include MFC after: 2 weeks --- sys/i386/linux/linux_locore.asm | 2 -- 1 file changed, 2 deletions(-) diff --git a/sys/i386/linux/linux_locore.asm b/sys/i386/linux/linux_locore.asm index 6b3cf01a8edc..9aef5ad21d26 100644 --- a/sys/i386/linux/linux_locore.asm +++ b/sys/i386/linux/linux_locore.asm @@ -5,8 +5,6 @@ #include /* system call numbers */ -#include "assym.inc" - .data .globl linux_platform
git: 8f9635dc99f5 - main - linux(4): Retire handmade DWARF annotations from signal trampolines
The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=8f9635dc99f571a0ae4e613b9a0439e68da7b160 commit 8f9635dc99f571a0ae4e613b9a0439e68da7b160 Author: Dmitry Chagin AuthorDate: 2022-05-15 18:08:12 + Commit: Dmitry Chagin CommitDate: 2022-05-15 18:08:12 + linux(4): Retire handmade DWARF annotations from signal trampolines The Linux exports __kernel_sigreturn and __kernel_rt_sigreturn from the vdso. Modern glibc's sigaction sets the sa_restorer field of sigaction to the corresponding vdso __sigreturn, and sets the SA_RESTORER. Our signal trampolines uses the FreeBSD-way to call a signal handler, so does not use the sigaction's sa_restorer. However, as glibc's runtime linker depends on the existment of the vdso __sigreturn symbols, for all Linuxulators was added separate trampolines named __sigcode with DWARF anotations and left separate __sigreturn methods, which are exported. MFC after: 2 weeks --- sys/amd64/linux/linux_genassym.c | 20 - sys/amd64/linux/linux_locore.asm | 92 sys/amd64/linux32/linux32_genassym.c | 17 +++- sys/amd64/linux32/linux32_locore.asm | 161 --- sys/amd64/linux32/linux32_sysvec.c | 8 +- sys/amd64/linux32/linux32_vdso.lds.s | 2 + sys/i386/linux/linux_genassym.c | 19 - sys/i386/linux/linux_locore.asm | 160 +++--- sys/i386/linux/linux_sysvec.c| 8 +- sys/i386/linux/linux_vdso.lds.s | 2 + 10 files changed, 259 insertions(+), 230 deletions(-) diff --git a/sys/amd64/linux/linux_genassym.c b/sys/amd64/linux/linux_genassym.c index a9658b006be8..14880afcc89b 100644 --- a/sys/amd64/linux/linux_genassym.c +++ b/sys/amd64/linux/linux_genassym.c @@ -12,5 +12,23 @@ __FBSDID("$FreeBSD$"); ASSYM(LINUX_RT_SIGF_UC, offsetof(struct l_rt_sigframe, sf_uc)); ASSYM(LINUX_RT_SIGF_SC, offsetof(struct l_ucontext, uc_mcontext)); +ASSYM(L_SC_R8, offsetof(struct l_sigcontext, sc_r8)); +ASSYM(L_SC_R9, offsetof(struct l_sigcontext, sc_r9)); +ASSYM(L_SC_R10, offsetof(struct l_sigcontext, sc_r10)); +ASSYM(L_SC_R11, offsetof(struct l_sigcontext, sc_r11)); +ASSYM(L_SC_R12, offsetof(struct l_sigcontext, sc_r12)); +ASSYM(L_SC_R13, offsetof(struct l_sigcontext, sc_r13)); +ASSYM(L_SC_R14, offsetof(struct l_sigcontext, sc_r14)); +ASSYM(L_SC_R15, offsetof(struct l_sigcontext, sc_r15)); +ASSYM(L_SC_RDI, offsetof(struct l_sigcontext, sc_rdi)); +ASSYM(L_SC_RSI, offsetof(struct l_sigcontext, sc_rsi)); +ASSYM(L_SC_RBP, offsetof(struct l_sigcontext, sc_rbp)); +ASSYM(L_SC_RBX, offsetof(struct l_sigcontext, sc_rbx)); +ASSYM(L_SC_RDX, offsetof(struct l_sigcontext, sc_rdx)); +ASSYM(L_SC_RAX, offsetof(struct l_sigcontext, sc_rax)); +ASSYM(L_SC_RCX, offsetof(struct l_sigcontext, sc_rcx)); +ASSYM(L_SC_RSP, offsetof(struct l_sigcontext, sc_rsp)); +ASSYM(L_SC_RIP, offsetof(struct l_sigcontext, sc_rip)); +ASSYM(L_SC_RFLAGS, offsetof(struct l_sigcontext, sc_rflags)); +ASSYM(L_SC_CS, offsetof(struct l_sigcontext, sc_cs)); ASSYM(LINUX_VERSION_CODE, LINUX_VERSION_CODE); -ASSYM(LINUX_SC_RSP, offsetof(struct l_sigcontext, sc_rsp)); diff --git a/sys/amd64/linux/linux_locore.asm b/sys/amd64/linux/linux_locore.asm index 8b6833d7352f..f26996980007 100644 --- a/sys/amd64/linux/linux_locore.asm +++ b/sys/amd64/linux/linux_locore.asm @@ -1,4 +1,31 @@ -/* $FreeBSD$ */ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2015-2022 Dmitry Chagin + * + * 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. + * + * $FreeBSD$ + */ #include "linux_assym.h" /* system definitions */ #include /* mis
git: 390c9ea029fd - main - linux(4): Add AT_MINSIGSTKSZ to arm64 port
The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=390c9ea029fdd3fb2ce61fc6b48617f0f7cd8754 commit 390c9ea029fdd3fb2ce61fc6b48617f0f7cd8754 Author: Dmitry Chagin AuthorDate: 2022-05-15 18:12:03 + Commit: Dmitry Chagin CommitDate: 2022-05-15 18:12:03 + linux(4): Add AT_MINSIGSTKSZ to arm64 port MFC after: 2 weeks --- sys/arm64/linux/linux.h | 5 + sys/arm64/linux/linux_sigframe.h | 2 ++ sys/arm64/linux/linux_sysvec.c | 1 + sys/compat/linux/linux_misc.h| 4 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/sys/arm64/linux/linux.h b/sys/arm64/linux/linux.h index dafec928c7e4..bf6e092f3bf8 100644 --- a/sys/arm64/linux/linux.h +++ b/sys/arm64/linux/linux.h @@ -81,7 +81,7 @@ typedef struct { #definel_fd_setfd_set /* Miscellaneous */ -#defineLINUX_AT_COUNT 20 +#defineLINUX_AT_COUNT 21 struct l___sysctl_args { @@ -163,9 +163,6 @@ struct l_newstat { #defineLINUX_SIG_UNBLOCK 1 #defineLINUX_SIG_SETMASK 2 -/* sigaltstack */ -#defineLINUX_MINSIGSTKSZ 5664/* sigframe */ - typedef void (*l_handler_t)(l_int); typedef struct { diff --git a/sys/arm64/linux/linux_sigframe.h b/sys/arm64/linux/linux_sigframe.h index d0d870e51375..3b125efc8781 100644 --- a/sys/arm64/linux/linux_sigframe.h +++ b/sys/arm64/linux/linux_sigframe.h @@ -81,4 +81,6 @@ struct l_sigframe { ucontext_t uc; }; +#defineLINUX_MINSIGSTKSZ roundup(sizeof(struct l_sigframe), 16) + #endif /* _ARM64_LINUX_SIGFRAME_H_ */ diff --git a/sys/arm64/linux/linux_sysvec.c b/sys/arm64/linux/linux_sysvec.c index 461a00bf5b33..e82539b9c5b1 100644 --- a/sys/arm64/linux/linux_sysvec.c +++ b/sys/arm64/linux/linux_sysvec.c @@ -197,6 +197,7 @@ linux_copyout_auxargs(struct image_params *imgp, uintptr_t base) issetugid = p->p_flag & P_SUGID ? 1 : 0; AUXARGS_ENTRY(pos, LINUX_AT_SYSINFO_EHDR, linux_vdso_base); + AUXARGS_ENTRY(pos, LINUX_AT_MINSIGSTKSZ, LINUX_MINSIGSTKSZ); AUXARGS_ENTRY(pos, LINUX_AT_HWCAP, *imgp->sysent->sv_hwcap); AUXARGS_ENTRY(pos, AT_PAGESZ, args->pagesz); AUXARGS_ENTRY(pos, LINUX_AT_CLKTCK, stclohz); diff --git a/sys/compat/linux/linux_misc.h b/sys/compat/linux/linux_misc.h index 0f134fc62e72..7a8073539e87 100644 --- a/sys/compat/linux/linux_misc.h +++ b/sys/compat/linux/linux_misc.h @@ -95,6 +95,10 @@ #defineLINUX_AT_RANDOM_LEN 16 /* size of random bytes */ +#ifndef LINUX_AT_MINSIGSTKSZ +#defineLINUX_AT_MINSIGSTKSZ51 /* min stack size required by the kernel */ +#endif + /* Linux sets the i387 to extended precision. */ #if defined(__i386__) || defined(__amd64__) #define__LINUX_NPXCW__ 0x37f
git: c56480a83235 - main - linux(4): Implement signal trampoline for arm64 in a FreeBSD-way
The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=c56480a832354aff995f9d0bc5da4ccf27dfe78a commit c56480a832354aff995f9d0bc5da4ccf27dfe78a Author: Dmitry Chagin AuthorDate: 2022-05-15 18:10:50 + Commit: Dmitry Chagin CommitDate: 2022-05-15 18:10:50 + linux(4): Implement signal trampoline for arm64 in a FreeBSD-way The implemenation differs from others Linuxulators. For unwinders Linux ucontext_t is stored, however native machine context is used to store/restore process state to avoid code duplication. As DWARF Aarch64 does not define a register number for PC and provides no direct way to encode the PC of the previous frame, CFI cannot describe a signal trampoline frame. So, modified the vdso linker script to discard unused sections. Extensions are not implemented. MFC after: 2 weeks --- sys/arm64/linux/linux.h | 2 +- sys/arm64/linux/linux_locore.asm | 15 +-- sys/arm64/linux/linux_sigframe.h | 62 ++- sys/arm64/linux/linux_sysvec.c | 90 ++-- sys/arm64/linux/linux_vdso.lds.s | 33 --- 5 files changed, 150 insertions(+), 52 deletions(-) diff --git a/sys/arm64/linux/linux.h b/sys/arm64/linux/linux.h index 402f7aa39bb9..dafec928c7e4 100644 --- a/sys/arm64/linux/linux.h +++ b/sys/arm64/linux/linux.h @@ -164,7 +164,7 @@ struct l_newstat { #defineLINUX_SIG_SETMASK 2 /* sigaltstack */ -#defineLINUX_MINSIGSTKSZ 2048/* XXX */ +#defineLINUX_MINSIGSTKSZ 5664/* sigframe */ typedef void (*l_handler_t)(l_int); diff --git a/sys/arm64/linux/linux_locore.asm b/sys/arm64/linux/linux_locore.asm index 0311c2e7e7e9..dfaafba155f2 100644 --- a/sys/arm64/linux/linux_locore.asm +++ b/sys/arm64/linux/linux_locore.asm @@ -3,6 +3,7 @@ * * Copyright (C) 2018 Turing Robotic Industries Inc. * Copyright (C) 2020 Andrew Turner + * Copyright (C) 2022 Dmitry Chagin * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -29,7 +30,7 @@ */ /* - * arm64 Linux VDSO implementation. + * arm64 Linux VDSO signal trampoline. */ #include @@ -45,8 +46,14 @@ linux_platform: .text nop /* This is what Linux calls a "Mysterious NOP". */ -ENTRY(__kernel_rt_sigreturn) +EENTRY(__kernel_rt_sigreturn) mov x8, #LINUX_SYS_linux_rt_sigreturn svc #0 - ret -END(__kernel_rt_sigreturn) +EEND(__kernel_rt_sigreturn) + +EENTRY(linux_vdso_sigcode) + blr x8 + + mov x8, #LINUX_SYS_linux_rt_sigreturn + svc #0 +EEND(linux_vdso_sigcode) diff --git a/sys/arm64/linux/linux_sigframe.h b/sys/arm64/linux/linux_sigframe.h index 060b89c920ac..d0d870e51375 100644 --- a/sys/arm64/linux/linux_sigframe.h +++ b/sys/arm64/linux/linux_sigframe.h @@ -1,7 +1,7 @@ /*- * Copyright (c) 1994-1996 Søren Schmidt - * Copyright (c) 2013 Dmitry Chagin * Copyright (c) 2018 Turing Robotic Industries Inc. + * Copyright (c) 2022 Dmitry Chagin * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -23,22 +23,62 @@ * 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. - */ - -/* + * * $FreeBSD$ */ + #ifndef _ARM64_LINUX_SIGFRAME_H_ #define_ARM64_LINUX_SIGFRAME_H_ -/* - * This structure is different from the one used by Linux, - * but it doesn't matter - it's not user-accessible. We need - * it instead of the native one because of l_siginfo. - */ +struct _l_aarch64_ctx { + uint32_tmagic; + uint32_tsize; +}; + +#defineL_FPSIMD_MAGIC 0x46508001 +#defineL_ESR_MAGIC 0x45535201 + +struct l_fpsimd_context { + struct _l_aarch64_ctx head; + uint32_tfpsr; + uint32_tfpcr; + __uint128_t vregs[32]; +}; + +struct l_esr_context { + struct _l_aarch64_ctx head; + uint64_tesr; +}; + +struct l_sigcontext { + uint64_tfault_address; + uint64_tregs[31]; + uint64_tsp; + uint64_tpc; + uint64_tpstate; + uint8_t __reserved[4096] __attribute__((__aligned__(16))); +}; + +struct l_ucontext { + unsigned long uc_flags; + struct l_ucontext *uc_link; + l_stack_t uc_stack; + l_sigset_t uc_sigmask; + uint8_t __glibc_hole[1024 / 8 - sizeof(l_sigset_t)]; + struct l_sigcontext uc_sc; +}; + +struct l_rt_sigframe { + l_siginfo_t sf_si; + struct l_ucontext sf_uc; +} __attribute__((__aligned__(16))); + struct l_sigframe { - struct l_siginfosf_si; -
git: 0b4f2ab0e913 - main - krpc: Fix NFS-over-TLS for KTLS1.3
The branch main has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=0b4f2ab0e91307bd1fa6e884b0fccef9d10d5a2d commit 0b4f2ab0e91307bd1fa6e884b0fccef9d10d5a2d Author: Rick Macklem AuthorDate: 2022-05-15 18:51:56 + Commit: Rick Macklem CommitDate: 2022-05-15 18:51:56 + krpc: Fix NFS-over-TLS for KTLS1.3 When NFS-over-TLS uses KTLS1.3, the client can receive post-handshake handshake records. These records can be safely thown away, but are not handled correctly via the rpctls_ct_handlerecord() upcall to the daemon. Commit 373511338d95 changed soreceive_generic() so that it will only return ENXIO for Alert records when MSG_TLSAPPDATA is specified. As such, the post-handshake handshake records will be returned to the krpc. This patch modifies the krpc so that it will throw these records away, which seems sufficient to make NFS-over-TLS work with KTLS1.3. This change has no effect on the use of KTLS1.2, since it does not generate post-handshake handshake records. MFC after: 2 weeks --- sys/rpc/clnt_vc.c | 21 + sys/rpc/svc_vc.c | 12 ++-- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/sys/rpc/clnt_vc.c b/sys/rpc/clnt_vc.c index f565de06f4bd..0c415d048141 100644 --- a/sys/rpc/clnt_vc.c +++ b/sys/rpc/clnt_vc.c @@ -944,7 +944,7 @@ clnt_vc_soupcall(struct socket *so, void *arg, int waitflag) { struct ct_data *ct = (struct ct_data *) arg; struct uio uio; - struct mbuf *m, *m2, **ctrlp; + struct mbuf *m, *m2; struct ct_request *cr; int error, rcvflag, foundreq; uint32_t xid_plus_direction[2], header; @@ -992,13 +992,10 @@ clnt_vc_soupcall(struct socket *so, void *arg, int waitflag) m2 = m = NULL; rcvflag = MSG_DONTWAIT | MSG_SOCALLBCK; if (ct->ct_sslrefno != 0 && (ct->ct_rcvstate & - RPCRCVSTATE_NORMAL) != 0) { + RPCRCVSTATE_NORMAL) != 0) rcvflag |= MSG_TLSAPPDATA; - ctrlp = NULL; - } else - ctrlp = &m2; SOCKBUF_UNLOCK(&so->so_rcv); - error = soreceive(so, NULL, &uio, &m, ctrlp, &rcvflag); + error = soreceive(so, NULL, &uio, &m, &m2, &rcvflag); SOCKBUF_LOCK(&so->so_rcv); if (error == EWOULDBLOCK) { @@ -1023,8 +1020,8 @@ clnt_vc_soupcall(struct socket *so, void *arg, int waitflag) } /* -* A return of ENXIO indicates that there is a -* non-application data record at the head of the +* A return of ENXIO indicates that there is an +* alert record at the head of the * socket's receive queue, for TLS connections. * This record needs to be handled in userland * via an SSL_read() call, so do an upcall to the daemon. @@ -1051,10 +1048,10 @@ clnt_vc_soupcall(struct socket *so, void *arg, int waitflag) cmsg->cmsg_len == CMSG_LEN(sizeof(tgr))) { memcpy(&tgr, CMSG_DATA(cmsg), sizeof(tgr)); /* -* This should have been handled by -* setting RPCRCVSTATE_UPCALLNEEDED in -* ct_rcvstate but if not, all we can do -* is toss it away. +* TLS_RLTYPE_ALERT records should be handled +* since soreceive() would have returned +* ENXIO. Just throw any other +* non-TLS_RLTYPE_APP records away. */ if (tgr.tls_type != TLS_RLTYPE_APP) { m_freem(m); diff --git a/sys/rpc/svc_vc.c b/sys/rpc/svc_vc.c index f0e0ee5d4d62..43d14c702d4e 100644 --- a/sys/rpc/svc_vc.c +++ b/sys/rpc/svc_vc.c @@ -804,8 +804,8 @@ tryagain: } /* -* A return of ENXIO indicates that there is a -* non-application data record at the head of the +* A return of ENXIO indicates that there is an +* alert record at the head of the * socket's receive queue, for TLS connections. * This record needs to be handled in userland * via an SSL_read() call, so do an upcall to the daemon. @@ -863,10 +863,10 @@ tryagain: cmsg->cmsg_len == CMSG_LEN(sizeof(tgr))) { memcpy(&tgr, CMSG_DATA(cmsg), sizeof(tgr)); /* -* This should have been handled by -
git: a1735a7698a6 - stable/13 - nfsd: Add a sanity check to SecinfoNoname for file type
The branch stable/13 has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=a1735a7698a60eff1e0682261033e37fc530f85d commit a1735a7698a60eff1e0682261033e37fc530f85d Author: Rick Macklem AuthorDate: 2022-05-01 20:41:31 + Commit: Rick Macklem CommitDate: 2022-05-15 19:17:11 + nfsd: Add a sanity check to SecinfoNoname for file type Robert Morris reported that, for the case of SecinfoNoname with the Parent option, providing a non-directory could cause a crash. This patch adds a sanity check for v_type == VDIR for this case, to avoid the crash. PR: 260300 (cherry picked from commit 47d75c29f5510ad844f0bc7fbc07d481ebb7fd9e) --- sys/fs/nfsserver/nfs_nfsdserv.c | 5 + 1 file changed, 5 insertions(+) diff --git a/sys/fs/nfsserver/nfs_nfsdserv.c b/sys/fs/nfsserver/nfs_nfsdserv.c index d72716ce7fd8..2bb113b6441d 100644 --- a/sys/fs/nfsserver/nfs_nfsdserv.c +++ b/sys/fs/nfsserver/nfs_nfsdserv.c @@ -3822,6 +3822,11 @@ nfsrvd_secinfononame(struct nfsrv_descript *nd, int isdgram, fhstyle = fxdr_unsigned(int, *tl); switch (fhstyle) { case NFSSECINFONONAME_PARENT: + if (dp->v_type != VDIR) { + vput(dp); + nd->nd_repstat = NFSERR_NOTDIR; + goto nfsmout; + } NFSNAMEICNDSET(&named.ni_cnd, nd->nd_cred, LOOKUP, LOCKLEAF | SAVESTART); nfsvno_setpathbuf(&named, &bufp, &hashp);
git: edc5b6ea881d - main - sctp: use sb_avail() when accessing sb_acc for reading
The branch main has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=edc5b6ea881d7e196fee8df7ebcd372f8f5b4469 commit edc5b6ea881d7e196fee8df7ebcd372f8f5b4469 Author: Michael Tuexen AuthorDate: 2022-05-14 10:38:43 + Commit: Michael Tuexen CommitDate: 2022-05-14 10:38:43 + sctp: use sb_avail() when accessing sb_acc for reading This is a cleanup to simplify a patch for PR 260116. PR: 260116 MFC after: 3 days --- sys/netinet/sctp_indata.c | 2 +- sys/netinet/sctp_os_bsd.h | 2 ++ sys/netinet/sctp_output.c | 2 +- sys/netinet/sctp_pcb.c| 2 +- sys/netinet/sctp_usrreq.c | 7 +++ sys/netinet/sctputil.c| 30 +++--- 6 files changed, 23 insertions(+), 22 deletions(-) diff --git a/sys/netinet/sctp_indata.c b/sys/netinet/sctp_indata.c index b43aa8208239..8a2c30827198 100644 --- a/sys/netinet/sctp_indata.c +++ b/sys/netinet/sctp_indata.c @@ -1942,7 +1942,7 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struct sctp_association *asoc, * When we have NO room in the rwnd we check to make sure * the reader is doing its job... */ - if (stcb->sctp_socket->so_rcv.sb_cc) { + if (SCTP_SBAVAIL(&stcb->sctp_socket->so_rcv) > 0) { /* some to read, wake-up */ sctp_sorwakeup(stcb->sctp_ep, stcb->sctp_socket); } diff --git a/sys/netinet/sctp_os_bsd.h b/sys/netinet/sctp_os_bsd.h index faca8a3b6276..8240fca64c48 100644 --- a/sys/netinet/sctp_os_bsd.h +++ b/sys/netinet/sctp_os_bsd.h @@ -381,6 +381,8 @@ typedef struct callout sctp_os_timer_t; #define SCTP_SORESERVE(so, send, recv) soreserve(so, send, recv) /* wakeup a socket */ #define SCTP_SOWAKEUP(so) wakeup(&(so)->so_timeo) +/* number of bytes ready to read */ +#define SCTP_SBAVAIL(sb) sbavail(sb) /* clear the socket buffer state */ #define SCTP_SB_CLEAR(sb) \ (sb).sb_cc = 0; \ diff --git a/sys/netinet/sctp_output.c b/sys/netinet/sctp_output.c index 3a891eb86116..2614e333e84e 100644 --- a/sys/netinet/sctp_output.c +++ b/sys/netinet/sctp_output.c @@ -11519,7 +11519,7 @@ jump_out: drp->current_onq = htonl(asoc->size_on_reasm_queue + asoc->size_on_all_streams + asoc->my_rwnd_control_len + - stcb->sctp_socket->so_rcv.sb_cc); + SCTP_SBAVAIL(&stcb->sctp_socket->so_rcv)); } else { /*- * If my rwnd is 0, possibly from mbuf depletion as well as diff --git a/sys/netinet/sctp_pcb.c b/sys/netinet/sctp_pcb.c index 09f5d86fa1a6..38c88d8ae8e4 100644 --- a/sys/netinet/sctp_pcb.c +++ b/sys/netinet/sctp_pcb.c @@ -3409,7 +3409,7 @@ sctp_inpcb_free(struct sctp_inpcb *inp, int immediate, int from) if ((stcb->asoc.size_on_reasm_queue > 0) || (stcb->asoc.control_pdapi) || (stcb->asoc.size_on_all_streams > 0) || - (so && (so->so_rcv.sb_cc > 0))) { + ((so != NULL) && (SCTP_SBAVAIL(&so->so_rcv) > 0))) { /* Left with Data unread */ struct mbuf *op_err; diff --git a/sys/netinet/sctp_usrreq.c b/sys/netinet/sctp_usrreq.c index 98102722c53e..05820f2b2859 100644 --- a/sys/netinet/sctp_usrreq.c +++ b/sys/netinet/sctp_usrreq.c @@ -545,7 +545,7 @@ sctp_close(struct socket *so) if ((inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) == 0) { inp->sctp_flags |= SCTP_PCB_FLAGS_SOCKET_GONE | SCTP_PCB_FLAGS_CLOSE_IP; if (((so->so_options & SO_LINGER) && (so->so_linger == 0)) || - (so->so_rcv.sb_cc > 0)) { + (SCTP_SBAVAIL(&so->so_rcv) > 0)) { #ifdef SCTP_LOG_CLOSING sctp_log_closing(inp, NULL, 13); #endif @@ -707,9 +707,8 @@ sctp_disconnect(struct socket *so) return (0); } NET_EPOCH_ENTER(et); - if (((so->so_options & SO_LINGER) && - (so->so_linger == 0)) || - (so->so_rcv.sb_cc > 0)) { + if (((so->so_options & SO_LINGER) && (so->so_linger == 0)) || + (SCTP_SBAVAIL(&so->so_rcv) > 0)) { if (SCTP_GET_STATE(stcb) != SCTP_STATE_COOKIE_WAIT) { /* Left with Data unread */ struct mbuf *op_err; diff --git a/sys/netinet/sctputil.c b/sys/netinet/sctputil.c index 8ec934e83cfc..a851631d2f74 100644 --- a/sys/netinet/sctputil.c +++ b/sys/netinet/sctputil.c @@ -76,7 +76,7 @@ sctp_sblog(struct sockbuf *sb, struct sctp_tcb *stcb, int from, int incr) struct sctp_cwnd_log sctp_clog; sctp_c
git: 187d7e982132 - main - Reduce code nesting in readsuper().
The branch main has been updated by mckusick: URL: https://cgit.FreeBSD.org/src/commit/?id=187d7e982132d0c971c16348118381076654ec37 commit 187d7e982132d0c971c16348118381076654ec37 Author: Kirk McKusick AuthorDate: 2022-05-15 22:01:14 + Commit: Kirk McKusick CommitDate: 2022-05-15 22:02:24 + Reduce code nesting in readsuper(). No functional change. --- sys/ufs/ffs/ffs_subr.c | 87 +- 1 file changed, 43 insertions(+), 44 deletions(-) diff --git a/sys/ufs/ffs/ffs_subr.c b/sys/ufs/ffs/ffs_subr.c index 45fc3aa2cb25..01e9f45e1205 100644 --- a/sys/ufs/ffs/ffs_subr.c +++ b/sys/ufs/ffs/ffs_subr.c @@ -253,7 +253,7 @@ readsuper(void *devfd, struct fs **fsp, off_t sblockloc, int isaltsblk, fs = *fsp; if (fs->fs_magic == FS_BAD_MAGIC) return (EINVAL); - if (((fs->fs_magic == FS_UFS1_MAGIC && (isaltsblk || + if (!(((fs->fs_magic == FS_UFS1_MAGIC && (isaltsblk || sblockloc <= SBLOCK_UFS1)) || (fs->fs_magic == FS_UFS2_MAGIC && (isaltsblk || sblockloc == fs->fs_sblockloc))) && @@ -261,54 +261,53 @@ readsuper(void *devfd, struct fs **fsp, off_t sblockloc, int isaltsblk, fs->fs_bsize >= MINBSIZE && fs->fs_bsize <= MAXBSIZE && fs->fs_bsize >= roundup(sizeof(struct fs), DEV_BSIZE) && - fs->fs_sbsize <= SBLOCKSIZE) { - /* -* If the filesystem has been run on a kernel without -* metadata check hashes, disable them. -*/ - if ((fs->fs_flags & FS_METACKHASH) == 0) - fs->fs_metackhash = 0; - /* -* Clear any check-hashes that are not maintained -* by this kernel. Also clear any unsupported flags. -*/ - fs->fs_metackhash &= CK_SUPPORTED; - fs->fs_flags &= FS_SUPPORTED; - if (fs->fs_ckhash != (ckhash = ffs_calc_sbhash(fs))) { - if (chkhash == STDSB_NOMSG) - return (EINTEGRITY); - if (chkhash == STDSB_NOHASHFAIL_NOMSG) - return (0); + fs->fs_sbsize <= SBLOCKSIZE)) + return (ENOENT); + /* +* If the filesystem has been run on a kernel without +* metadata check hashes, disable them. +*/ + if ((fs->fs_flags & FS_METACKHASH) == 0) + fs->fs_metackhash = 0; + /* +* Clear any check-hashes that are not maintained +* by this kernel. Also clear any unsupported flags. +*/ + fs->fs_metackhash &= CK_SUPPORTED; + fs->fs_flags &= FS_SUPPORTED; + if (fs->fs_ckhash != (ckhash = ffs_calc_sbhash(fs))) { + if (chkhash == STDSB_NOMSG) + return (EINTEGRITY); + if (chkhash == STDSB_NOHASHFAIL_NOMSG) + return (0); #ifdef _KERNEL - res = uprintf("Superblock check-hash failed: recorded " - "check-hash 0x%x != computed check-hash 0x%x%s\n", - fs->fs_ckhash, ckhash, - chkhash == STDSB_NOHASHFAIL ? " (Ignored)" : ""); + res = uprintf("Superblock check-hash failed: recorded " + "check-hash 0x%x != computed check-hash 0x%x%s\n", + fs->fs_ckhash, ckhash, + chkhash == STDSB_NOHASHFAIL ? " (Ignored)" : ""); #else - res = 0; + res = 0; #endif - /* -* Print check-hash failure if no controlling terminal -* in kernel or always if in user-mode (libufs). -*/ - if (res == 0) - printf("Superblock check-hash failed: recorded " - "check-hash 0x%x != computed check-hash " - "0x%x%s\n", fs->fs_ckhash, ckhash, - chkhash == STDSB_NOHASHFAIL ? - " (Ignored)" : ""); - if (chkhash == STDSB) - return (EINTEGRITY); - /* chkhash == STDSB_NOHASHFAIL */ - return (0); - } - /* Have to set for old filesystems that predate this field */ - fs->fs_sblockactualloc = sblockloc; - /* Not yet any summary information */ - fs->fs_si = NULL; + /* +* Print check-hash failure if no controlling terminal +* in kernel or always if in user-mode (libufs). +*/ + if (res == 0) + printf("Superblock check-hash failed: recorded " + "check-hash 0x%x
git: bf0aa72f1f59 - main - igc: Update PCI IDs
The branch main has been updated by kbowling (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=bf0aa72f1f5911912817a2d3feb4010c8239512c commit bf0aa72f1f5911912817a2d3feb4010c8239512c Author: Kevin Bowling AuthorDate: 2022-05-15 22:07:59 + Commit: Kevin Bowling CommitDate: 2022-05-15 22:09:58 + igc: Update PCI IDs I226-K PCI ID got clarified by intel. Add a new I226 ID while here. Approved by:grehan MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D35218 --- sys/dev/igc/if_igc.c | 1 + sys/dev/igc/igc_hw.h | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/sys/dev/igc/if_igc.c b/sys/dev/igc/if_igc.c index f2803c01850e..10f76b44ea45 100644 --- a/sys/dev/igc/if_igc.c +++ b/sys/dev/igc/if_igc.c @@ -59,6 +59,7 @@ static pci_vendor_info_t igc_vendor_info_array[] = PVID(0x8086, IGC_DEV_ID_I225_K2, "Intel(R) Ethernet Controller I225-K(2)"), PVID(0x8086, IGC_DEV_ID_I225_LMVP, "Intel(R) Ethernet Controller I225-LMvP(2)"), PVID(0x8086, IGC_DEV_ID_I226_K, "Intel(R) Ethernet Controller I226-K"), + PVID(0x8086, IGC_DEV_ID_I226_LVMP, "Intel(R) Ethernet Controller I226-LMvP"), PVID(0x8086, IGC_DEV_ID_I225_IT, "Intel(R) Ethernet Controller I225-IT(2)"), PVID(0x8086, IGC_DEV_ID_I226_LM, "Intel(R) Ethernet Controller I226-LM"), PVID(0x8086, IGC_DEV_ID_I226_V, "Intel(R) Ethernet Controller I226-V"), diff --git a/sys/dev/igc/igc_hw.h b/sys/dev/igc/igc_hw.h index a8323a8578a9..6a22593584ce 100644 --- a/sys/dev/igc/igc_hw.h +++ b/sys/dev/igc/igc_hw.h @@ -22,7 +22,8 @@ struct igc_hw; #define IGC_DEV_ID_I220_V 0x15F7 #define IGC_DEV_ID_I225_K2 0x3101 #define IGC_DEV_ID_I225_LMVP 0x5502 -#define IGC_DEV_ID_I226_K 0x5504 +#define IGC_DEV_ID_I226_K 0x3102 +#define IGC_DEV_ID_I226_LMVP 0x5503 #define IGC_DEV_ID_I225_IT 0x0D9F #define IGC_DEV_ID_I226_LM 0x125B #define IGC_DEV_ID_I226_V 0x125C
Re: git: 349cc55c9796 - main - Merge llvm-project main llvmorg-14-init-10186-gff7f2cfa959b
Dimitry Andric wrote: The branch main has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=349cc55c9796c4596a5b9904cd3281af295f878f commit 349cc55c9796c4596a5b9904cd3281af295f878f Merge: cb2ae6163174 c0981da47d56 Author: Dimitry Andric AuthorDate: 2022-03-20 11:40:34 + Commit: Dimitry Andric CommitDate: 2022-05-14 11:43:05 + Merge llvm-project main llvmorg-14-init-10186-gff7f2cfa959b This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp to llvmorg-14-init-10186-gff7f2cfa959b. PR: 261742 MFC after: 2 weeks .../llvm-project/compiler-rt/lib/builtins/atomic.c | 15 + This errors out on -CURRENT immediately preceding this whole LLVM 14 merge: --- atomic.o --- /usr/src/contrib/llvm-project/compiler-rt/lib/builtins/atomic.c:367:1: error: implicit declaration of function '__c11_atomic_fetch_nand' is invalid in C99 [-Werror, -Wimplicit-function-declaration] OPTIMISED_CASES ^ /usr/src/contrib/llvm-project/compiler-rt/lib/builtins/atomic.c:249:3: note: expanded from macro 'OPTIMISED_CASES' OPTIMISED_CASE(1, IS_LOCK_FREE_1, uint8_t) \ ^ /usr/src/contrib/llvm-project/compiler-rt/lib/builtins/atomic.c:366:43: note: expanded from macro 'OPTIMISED_CASE' #define OPTIMISED_CASE(n, lockfree, type) ATOMIC_RMW_NAND(n, lockfree, type) ^ /usr/src/contrib/llvm-project/compiler-rt/lib/builtins/atomic.c:342:14: note: expanded from macro 'ATOMIC_RMW_NAND' return __c11_atomic_fetch_nand((_Atomic(type) *)ptr, val, model); \ ^ /usr/src/contrib/llvm-project/compiler-rt/lib/builtins/atomic.c:367:1: note: did you mean '__c11_atomic_fetch_and'? /usr/src/contrib/llvm-project/compiler-rt/lib/builtins/atomic.c:249:3: note: expanded from macro 'OPTIMISED_CASES' OPTIMISED_CASE(1, IS_LOCK_FREE_1, uint8_t) \ ^ /usr/src/contrib/llvm-project/compiler-rt/lib/builtins/atomic.c:366:43: note: expanded from macro 'OPTIMISED_CASE' #define OPTIMISED_CASE(n, lockfree, type) ATOMIC_RMW_NAND(n, lockfree, type) ^ /usr/src/contrib/llvm-project/compiler-rt/lib/builtins/atomic.c:342:14: note: expanded from macro 'ATOMIC_RMW_NAND' return __c11_atomic_fetch_nand((_Atomic(type) *)ptr, val, model); \ ^ /usr/src/contrib/llvm-project/compiler-rt/lib/builtins/atomic.c:358:1: note: '__c11_atomic_fetch_and' declared here OPTIMISED_CASES ^ /usr/src/contrib/llvm-project/compiler-rt/lib/builtins/atomic.c:249:3: note: expanded from macro 'OPTIMISED_CASES' OPTIMISED_CASE(1, IS_LOCK_FREE_1, uint8_t) \ ^ /usr/src/contrib/llvm-project/compiler-rt/lib/builtins/atomic.c:357:43: note: expanded from macro 'OPTIMISED_CASE' #define OPTIMISED_CASE(n, lockfree, type) ATOMIC_RMW(n, lockfree, type, and, &) ^ /usr/src/contrib/llvm-project/compiler-rt/lib/builtins/atomic.c:330:14: note: expanded from macro 'ATOMIC_RMW' return __c11_atomic_fetch_##opname((_Atomic(type) *)ptr, val, model);\ ^ :35:1: note: expanded from here __c11_atomic_fetch_and ^ /usr/src/contrib/llvm-project/compiler-rt/lib/builtins/atomic.c:367:1: error: implicit declaration of function '__c11_atomic_fetch_nand' is invalid in C99 [-Werror, -Wimplicit-function-declaration] OPTIMISED_CASES ^ /usr/src/contrib/llvm-project/compiler-rt/lib/builtins/atomic.c:250:3: note: expanded from macro 'OPTIMISED_CASES' OPTIMISED_CASE(2, IS_LOCK_FREE_2, uint16_t) \ ^ /usr/src/contrib/llvm-project/compiler-rt/lib/builtins/atomic.c:366:43: note: expanded from macro 'OPTIMISED_CASE' #define OPTIMISED_CASE(n, lockfree, type) ATOMIC_RMW_NAND(n, lockfree, type) ^ /usr/src/contrib/llvm-project/compiler-rt/lib/builtins/atomic.c:342:14: note: expanded from macro 'ATOMIC_RMW_NAND' return __c11_atomic_fetch_nand((_Atomic(type) *)ptr, val, model); \ ^ /usr/src/contrib/llvm-project/compiler-rt/lib/builtins/atomic.c:367:1: error: implicit declaration of function '__c11_atomic_fetch_nand' is invalid in C99 [-Werror, -Wimplicit-function-declaration] /usr/src/contrib/llvm-project/compiler-rt/lib/builtins/atomic.c:251:3: note: expanded from macro 'OPTIMISED_CASES' OPTIMISED_CASE(4, IS_LOCK_FREE_4, uint32_t) \ ^ /usr/src/contrib/llvm-project/compiler-rt/lib/builtins/atomic.c:366:43: note: expanded from macro 'OPTIMISED_CASE' #define OPTIMISED_CASE(n, lockfree, type) ATOMIC_RMW_NAND(n, lockfree, type) ^ /usr/src/contrib/llvm-project/compiler-rt/lib/builtins/atomic.c:342:14: note: expanded from macro 'ATOMIC_RMW_NAND' return __c11_atomic_fetch_nand((_Atomic(type) *)ptr, val, model); \ ^ /usr/src/contrib/llvm-project/compiler-rt/lib/builtins/atomic.c:367:1: error: implicit declaration of func
git: 48a1a6be1968 - main - igc: Fix typo in PCI ID define usage
The branch main has been updated by kbowling (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=48a1a6be1968e600235afd0f2b78bf633c065430 commit 48a1a6be1968e600235afd0f2b78bf633c065430 Author: Kevin Bowling AuthorDate: 2022-05-15 23:13:06 + Commit: Kevin Bowling CommitDate: 2022-05-15 23:17:49 + igc: Fix typo in PCI ID define usage Reported by:jenkins Fixes: bf0aa72f1f59 igc: Update PCI IDs MFC after: 3 days --- sys/dev/igc/if_igc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/dev/igc/if_igc.c b/sys/dev/igc/if_igc.c index 10f76b44ea45..bce3d16b5352 100644 --- a/sys/dev/igc/if_igc.c +++ b/sys/dev/igc/if_igc.c @@ -59,7 +59,7 @@ static pci_vendor_info_t igc_vendor_info_array[] = PVID(0x8086, IGC_DEV_ID_I225_K2, "Intel(R) Ethernet Controller I225-K(2)"), PVID(0x8086, IGC_DEV_ID_I225_LMVP, "Intel(R) Ethernet Controller I225-LMvP(2)"), PVID(0x8086, IGC_DEV_ID_I226_K, "Intel(R) Ethernet Controller I226-K"), - PVID(0x8086, IGC_DEV_ID_I226_LVMP, "Intel(R) Ethernet Controller I226-LMvP"), + PVID(0x8086, IGC_DEV_ID_I226_LMVP, "Intel(R) Ethernet Controller I226-LMvP"), PVID(0x8086, IGC_DEV_ID_I225_IT, "Intel(R) Ethernet Controller I225-IT(2)"), PVID(0x8086, IGC_DEV_ID_I226_LM, "Intel(R) Ethernet Controller I226-LM"), PVID(0x8086, IGC_DEV_ID_I226_V, "Intel(R) Ethernet Controller I226-V"),
git: 5c332527d15f - stable/13 - ng_pppoe: introduce new sysctl net.graph.pppoe.lcp_pcp
The branch stable/13 has been updated by eugen: URL: https://cgit.FreeBSD.org/src/commit/?id=5c332527d15fa3bd93e157477454dfe0bab68cd7 commit 5c332527d15fa3bd93e157477454dfe0bab68cd7 Author: Eugene Grosbein AuthorDate: 2022-05-01 16:34:08 + Commit: Eugene Grosbein CommitDate: 2022-05-16 02:31:56 + ng_pppoe: introduce new sysctl net.graph.pppoe.lcp_pcp New sysctl allows to mark transmitted PPPoE LCP Control ethernet frames with needed 3-bit Priority Code Point (PCP) value. Confirming driver like if_vlan(4) uses the value to fill IEEE 802.1p class of service field. This is similar to Cisco IOS "control-packets vlan cos priority" command. It helps to avoid premature disconnection of user sessions due to control frame drops (LCP Echo etc.) if network infrastructure has a botteleck at a switch or the xdsl DSLAM. See also: https://sourceforge.net/p/mpd/discussion/44692/thread/c7abe70e3a/ Tested by: Klaus Fokuhl at SourceForge (cherry picked from commit 2e547442ab3822d3d7c46a68f152032ef5fe337c) (cherry picked from commit 28903f396af4b151e16ea606cda66a9244fb179f) --- share/man/man4/ng_pppoe.4 | 17 +++-- sys/netgraph/ng_pppoe.c | 22 ++ 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/share/man/man4/ng_pppoe.4 b/share/man/man4/ng_pppoe.4 index d4ca53e68714..ff53d4ef3a95 100644 --- a/share/man/man4/ng_pppoe.4 +++ b/share/man/man4/ng_pppoe.4 @@ -35,7 +35,7 @@ .\" $FreeBSD$ .\" $Whistle: ng_pppoe.8,v 1.1 1999/01/25 23:46:27 archie Exp $ .\" -.Dd February 14, 2018 +.Dd May 1, 2022 .Dt NG_PPPOE 4 .Os .Sh NAME @@ -320,6 +320,18 @@ This node shuts down upon receipt of a control message, when all session have been disconnected or when the .Dv ethernet hook is disconnected. +.Sh SYSCTL VARIABLES +The node can mark transmitted LCP Ethernet packets (protocol 0xc021) +with 3-bit Priority Code Point (PCP) referring to IEEE 802.1p +class of service with following +.Xr sysctl 8 +variable. +.Bl -tag -width indent +.It Va net.graph.pppoe.lcp_pcp: 0..7 (default: 0) +Set it to non-zero value to be used by parent network interface driver +like +.Xr vlan 4 +.El .Sh EXAMPLES The following code uses .Dv libnetgraph @@ -556,7 +568,8 @@ setup(char *ethername, char *service, char *sessname, .Xr ng_ppp 4 , .Xr ng_socket 4 , .Xr ngctl 8 , -.Xr ppp 8 +.Xr ppp 8 , +.Xr vlan 4 .Rs .%A L. Mamakos .%A K. Lidl diff --git a/sys/netgraph/ng_pppoe.c b/sys/netgraph/ng_pppoe.c index e07f77b9d541..92a17286ccae 100644 --- a/sys/netgraph/ng_pppoe.c +++ b/sys/netgraph/ng_pppoe.c @@ -49,8 +49,13 @@ #include #include #include +#include +#include #include #include +#include +#include +#include #include #include @@ -64,8 +69,19 @@ static MALLOC_DEFINE(M_NETGRAPH_PPPOE, "netgraph_pppoe", "netgraph pppoe node"); #define M_NETGRAPH_PPPOE M_NETGRAPH #endif +/* Some PPP protocol numbers we're interested in */ +#define PROT_LCP 0xc021 + #define SIGNOFF "session closed" +VNET_DEFINE_STATIC(u_int32_t, ng_pppoe_lcp_pcp) = 0; +#define V_ng_pppoe_lcp_pcp VNET(ng_pppoe_lcp_pcp) + +SYSCTL_NODE(_net_graph, OID_AUTO, pppoe, CTLFLAG_RW, 0, "PPPoE"); +SYSCTL_UINT(_net_graph_pppoe, OID_AUTO, lcp_pcp, + CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(ng_pppoe_lcp_pcp), 0, + "Set PCP for LCP"); + /* * This section contains the netgraph method declarations for the * pppoe node. These methods define the netgraph pppoe 'type'. @@ -1438,6 +1454,12 @@ ng_pppoe_rcvdata(hook_p hook, item_p item) mtod(m, u_char *)[1] == 0x03) m_adj(m, 2); } + + if (V_ng_pppoe_lcp_pcp && m->m_pkthdr.len >= 2 && + m->m_len >= 2 && (m = m_pullup(m, 2)) && + mtod(m, uint16_t *)[0] == htons(PROT_LCP)) + EVL_APPLY_PRI(m, (uint8_t)(V_ng_pppoe_lcp_pcp & 0x7)); + /* * Bang in a pre-made header, and set the length up * to be correct. Then send it to the ethernet driver.
git: 14601708d59b - stable/12 - ng_pppoe: MFC: introduce new sysctl net.graph.pppoe.lcp_pcp
The branch stable/12 has been updated by eugen: URL: https://cgit.FreeBSD.org/src/commit/?id=14601708d59b97ab8cd834cd1124982ea5e7dc81 commit 14601708d59b97ab8cd834cd1124982ea5e7dc81 Author: Eugene Grosbein AuthorDate: 2022-05-01 16:34:08 + Commit: Eugene Grosbein CommitDate: 2022-05-16 03:11:26 + ng_pppoe: MFC: introduce new sysctl net.graph.pppoe.lcp_pcp New sysctl allows to mark transmitted PPPoE LCP Control ethernet frames with needed 3-bit Priority Code Point (PCP) value. Confirming driver like if_vlan(4) uses the value to fill IEEE 802.1p class of service field. This is similar to Cisco IOS "control-packets vlan cos priority" command. It helps to avoid premature disconnection of user sessions due to control frame drops (LCP Echo etc.) if network infrastructure has a botteleck at a switch or the xdsl DSLAM. See also: https://sourceforge.net/p/mpd/discussion/44692/thread/c7abe70e3a/ Tested by: Klaus Fokuhl at SourceForge (cherry picked from commit 2e547442ab3822d3d7c46a68f152032ef5fe337c) (cherry picked from commit 28903f396af4b151e16ea606cda66a9244fb179f) --- share/man/man4/ng_pppoe.4 | 17 +++-- sys/netgraph/ng_pppoe.c | 23 +++ 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/share/man/man4/ng_pppoe.4 b/share/man/man4/ng_pppoe.4 index 7b0aee78a6cf..fa967832a4cb 100644 --- a/share/man/man4/ng_pppoe.4 +++ b/share/man/man4/ng_pppoe.4 @@ -35,7 +35,7 @@ .\" $FreeBSD$ .\" $Whistle: ng_pppoe.8,v 1.1 1999/01/25 23:46:27 archie Exp $ .\" -.Dd February 14, 2018 +.Dd May 1, 2022 .Dt NG_PPPOE 4 .Os .Sh NAME @@ -320,6 +320,18 @@ This node shuts down upon receipt of a control message, when all session have been disconnected or when the .Dv ethernet hook is disconnected. +.Sh SYSCTL VARIABLES +The node can mark transmitted LCP Ethernet packets (protocol 0xc021) +with 3-bit Priority Code Point (PCP) referring to IEEE 802.1p +class of service with following +.Xr sysctl 8 +variable. +.Bl -tag -width indent +.It Va net.graph.pppoe.lcp_pcp: 0..7 (default: 0) +Set it to non-zero value to be used by parent network interface driver +like +.Xr vlan 4 +.El .Sh EXAMPLES The following code uses .Dv libnetgraph @@ -556,7 +568,8 @@ setup(char *ethername, char *service, char *sessname, .Xr ng_ppp 4 , .Xr ng_socket 4 , .Xr ngctl 8 , -.Xr ppp 8 +.Xr ppp 8 , +.Xr vlan 4 .Rs .%A L. Mamakos .%A K. Lidl diff --git a/sys/netgraph/ng_pppoe.c b/sys/netgraph/ng_pppoe.c index b15208217281..f0f4cc741e3b 100644 --- a/sys/netgraph/ng_pppoe.c +++ b/sys/netgraph/ng_pppoe.c @@ -48,8 +48,14 @@ #include #include #include +#include +#include +#include #include #include +#include +#include +#include #include #include @@ -63,8 +69,19 @@ static MALLOC_DEFINE(M_NETGRAPH_PPPOE, "netgraph_pppoe", "netgraph pppoe node"); #define M_NETGRAPH_PPPOE M_NETGRAPH #endif +/* Some PPP protocol numbers we're interested in */ +#define PROT_LCP 0xc021 + #define SIGNOFF "session closed" +VNET_DEFINE_STATIC(u_int32_t, ng_pppoe_lcp_pcp) = 0; +#define V_ng_pppoe_lcp_pcp VNET(ng_pppoe_lcp_pcp) + +SYSCTL_NODE(_net_graph, OID_AUTO, pppoe, CTLFLAG_RW, 0, "PPPoE"); +SYSCTL_UINT(_net_graph_pppoe, OID_AUTO, lcp_pcp, + CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(ng_pppoe_lcp_pcp), 0, + "Set PCP for LCP"); + /* * This section contains the netgraph method declarations for the * pppoe node. These methods define the netgraph pppoe 'type'. @@ -1432,6 +1449,12 @@ ng_pppoe_rcvdata(hook_p hook, item_p item) mtod(m, u_char *)[1] == 0x03) m_adj(m, 2); } + + if (V_ng_pppoe_lcp_pcp && m->m_pkthdr.len >= 2 && + m->m_len >= 2 && (m = m_pullup(m, 2)) && + mtod(m, uint16_t *)[0] == htons(PROT_LCP)) + EVL_APPLY_PRI(m, (uint8_t)(V_ng_pppoe_lcp_pcp & 0x7)); + /* * Bang in a pre-made header, and set the length up * to be correct. Then send it to the ethernet driver.