svn commit: r368657 - head/libexec/tftpd

2020-12-15 Thread Michael Tuexen
Author: tuexen
Date: Tue Dec 15 09:43:18 2020
New Revision: 368657
URL: https://svnweb.freebsd.org/changeset/base/368657

Log:
  When receiving a file having a length, which is a mulitple of the blocksize,
  close the file once it is received.
  
  Reported by:  Timo Voelker
  MFC after:1 week

Modified:
  head/libexec/tftpd/tftp-transfer.c

Modified: head/libexec/tftpd/tftp-transfer.c
==
--- head/libexec/tftpd/tftp-transfer.c  Tue Dec 15 08:29:45 2020
(r368656)
+++ head/libexec/tftpd/tftp-transfer.c  Tue Dec 15 09:43:18 2020
(r368657)
@@ -397,9 +397,9 @@ tftp_receive(int peer, uint16_t *block, struct tftp_st
send_error(peer, ENOSPACE);
goto abort;
}
-   if (n_data != segsize)
-   write_close();
}
+   if (n_data != segsize)
+   write_close();
windowblock++;
 
/* Only send ACKs for the last block in the window. */
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r368647 - head/libexec/tftpd

2020-12-14 Thread Michael Tuexen
Author: tuexen
Date: Mon Dec 14 22:13:58 2020
New Revision: 368647
URL: https://svnweb.freebsd.org/changeset/base/368647

Log:
  Improve the counting of blocks used to transfer a file from the
  server to the client in case of not using an OACK: Don't miss
  the first block in case of it is not also the last one.
  
  MFC after:1 week

Modified:
  head/libexec/tftpd/tftp-transfer.c

Modified: head/libexec/tftpd/tftp-transfer.c
==
--- head/libexec/tftpd/tftp-transfer.c  Mon Dec 14 22:07:07 2020
(r368646)
+++ head/libexec/tftpd/tftp-transfer.c  Mon Dec 14 22:13:58 2020
(r368647)
@@ -258,6 +258,7 @@ tftp_receive(int peer, uint16_t *block, struct tftp_st
if (firstblock != NULL) {
writesize = write_file(firstblock->th_data, fb_size);
ts->amount += writesize;
+   ts->blocks++;
windowblock++;
if (windowsize == 1 || fb_size != segsize) {
for (i = 0; ; i++) {
@@ -280,7 +281,6 @@ tftp_receive(int peer, uint16_t *block, struct tftp_st
}
 
if (fb_size != segsize) {
-   ts->blocks++;
write_close();
gettimeofday(&(ts->tstop), NULL);
return;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r368622 - head/sys/netinet

2020-12-13 Thread Michael Tuexen
Author: tuexen
Date: Sun Dec 13 23:51:51 2020
New Revision: 368622
URL: https://svnweb.freebsd.org/changeset/base/368622

Log:
  Harden the handling of outgoing streams in case of an restart or INIT
  collision. This avouds an out-of-bounce access in case the peer can
  break the cookie signature. Thanks to Felix Wilhelm from Google for
  reporting the issue.
  
  MFC after:1 week

Modified:
  head/sys/netinet/sctp_input.c

Modified: head/sys/netinet/sctp_input.c
==
--- head/sys/netinet/sctp_input.c   Sun Dec 13 23:32:50 2020
(r368621)
+++ head/sys/netinet/sctp_input.c   Sun Dec 13 23:51:51 2020
(r368622)
@@ -1699,7 +1699,9 @@ sctp_process_cookie_existing(struct mbuf *m, int iphle
NULL);
}
asoc->my_rwnd = ntohl(initack_cp->init.a_rwnd);
-   asoc->pre_open_streams = 
ntohs(initack_cp->init.num_outbound_streams);
+   if (asoc->pre_open_streams < asoc->streamoutcnt) {
+   asoc->pre_open_streams = asoc->streamoutcnt;
+   }
 
if (ntohl(init_cp->init.initiate_tag) != asoc->peer_vtag) {
/*
@@ -1831,7 +1833,9 @@ sctp_process_cookie_existing(struct mbuf *m, int iphle
/* move to OPEN state, if not in SHUTDOWN_SENT */
SCTP_SET_STATE(stcb, SCTP_STATE_OPEN);
}
-   asoc->pre_open_streams = 
ntohs(initack_cp->init.num_outbound_streams);
+   if (asoc->pre_open_streams < asoc->streamoutcnt) {
+   asoc->pre_open_streams = asoc->streamoutcnt;
+   }
asoc->init_seq_number = ntohl(initack_cp->init.initial_tsn);
asoc->sending_seq = asoc->asconf_seq_out = 
asoc->str_reset_seq_out = asoc->init_seq_number;
asoc->asconf_seq_out_acked = asoc->asconf_seq_out - 1;
@@ -2108,7 +2112,6 @@ sctp_process_cookie_new(struct mbuf *m, int iphlen, in
/* process the INIT-ACK info (my info) */
asoc->my_vtag = ntohl(initack_cp->init.initiate_tag);
asoc->my_rwnd = ntohl(initack_cp->init.a_rwnd);
-   asoc->pre_open_streams = ntohs(initack_cp->init.num_outbound_streams);
asoc->init_seq_number = ntohl(initack_cp->init.initial_tsn);
asoc->sending_seq = asoc->asconf_seq_out = asoc->str_reset_seq_out = 
asoc->init_seq_number;
asoc->asconf_seq_out_acked = asoc->asconf_seq_out - 1;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r368593 - head/sys/netinet

2020-12-12 Thread Michael Tuexen
Author: tuexen
Date: Sat Dec 12 22:23:45 2020
New Revision: 368593
URL: https://svnweb.freebsd.org/changeset/base/368593

Log:
  Clean up more resouces of an existing SCTP association in case of
  a restart.
  
  This fixes a use-after-free scenario, which was reported by Felix
  Wilhelm from Google in case a peer is able to modify the cookie.
  However, this can also be triggered by an assciation restart under
  some specific conditions.
  
  MFC after:1 week

Modified:
  head/sys/netinet/sctp_input.c

Modified: head/sys/netinet/sctp_input.c
==
--- head/sys/netinet/sctp_input.c   Sat Dec 12 21:33:19 2020
(r368592)
+++ head/sys/netinet/sctp_input.c   Sat Dec 12 22:23:45 2020
(r368593)
@@ -1428,6 +1428,11 @@ sctp_process_cookie_existing(struct mbuf *m, int iphle
struct sctp_association *asoc;
struct sctp_init_chunk *init_cp, init_buf;
struct sctp_init_ack_chunk *initack_cp, initack_buf;
+   struct sctp_asconf_addr *aparam, *naparam;
+   struct sctp_asconf_ack *aack, *naack;
+   struct sctp_tmit_chunk *chk, *nchk;
+   struct sctp_stream_reset_list *strrst, *nstrrst;
+   struct sctp_queued_to_read *sq, *nsq;
struct sctp_nets *net;
struct mbuf *op_err;
struct timeval old;
@@ -1705,7 +1710,6 @@ sctp_process_cookie_existing(struct mbuf *m, int iphle
 * still take a timeout to move these.. but it can't
 * hurt to mark them.
 */
-   struct sctp_tmit_chunk *chk;
 
TAILQ_FOREACH(chk, >asoc.sent_queue, sctp_next) {
if (chk->sent < SCTP_DATAGRAM_RESEND) {
@@ -1868,6 +1872,57 @@ sctp_process_cookie_existing(struct mbuf *m, int iphle
stcb->asoc.strmout[i].next_mid_unordered = 0;
stcb->asoc.strmout[i].last_msg_incomplete = 0;
}
+   TAILQ_FOREACH_SAFE(strrst, >resetHead, next_resp, 
nstrrst) {
+   TAILQ_REMOVE(>resetHead, strrst, next_resp);
+   SCTP_FREE(strrst, SCTP_M_STRESET);
+   }
+   TAILQ_FOREACH_SAFE(sq, >pending_reply_queue, next, nsq) {
+   TAILQ_REMOVE(>pending_reply_queue, sq, next);
+   if (sq->data) {
+   sctp_m_freem(sq->data);
+   sq->data = NULL;
+   }
+   sctp_free_remote_addr(sq->whoFrom);
+   sq->whoFrom = NULL;
+   sq->stcb = NULL;
+   sctp_free_a_readq(stcb, sq);
+   }
+   TAILQ_FOREACH_SAFE(chk, >control_send_queue, sctp_next, 
nchk) {
+   TAILQ_REMOVE(>control_send_queue, chk, sctp_next);
+   if (chk->data) {
+   sctp_m_freem(chk->data);
+   chk->data = NULL;
+   }
+   if (chk->holds_key_ref)
+   sctp_auth_key_release(stcb, chk->auth_keyid, 
SCTP_SO_LOCKED);
+   sctp_free_remote_addr(chk->whoTo);
+   SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_chunk), chk);
+   SCTP_DECR_CHK_COUNT();
+   }
+   TAILQ_FOREACH_SAFE(chk, >asconf_send_queue, sctp_next, 
nchk) {
+   TAILQ_REMOVE(>asconf_send_queue, chk, sctp_next);
+   if (chk->data) {
+   sctp_m_freem(chk->data);
+   chk->data = NULL;
+   }
+   if (chk->holds_key_ref)
+   sctp_auth_key_release(stcb, chk->auth_keyid, 
SCTP_SO_LOCKED);
+   sctp_free_remote_addr(chk->whoTo);
+   SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_chunk), chk);
+   SCTP_DECR_CHK_COUNT();
+   }
+   TAILQ_FOREACH_SAFE(aparam, >asconf_queue, next, naparam) {
+   TAILQ_REMOVE(>asconf_queue, aparam, next);
+   SCTP_FREE(aparam, SCTP_M_ASC_ADDR);
+   }
+   TAILQ_FOREACH_SAFE(aack, >asconf_ack_sent, next, naack) {
+   TAILQ_REMOVE(>asconf_ack_sent, aack, next);
+   if (aack->data != NULL) {
+   sctp_m_freem(aack->data);
+   }
+   SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_asconf_ack), 
aack);
+   }
+
/* process the INIT-ACK info (my info) */
asoc->my_vtag = ntohl(initack_cp->init.initiate_tag);
asoc->my_rwnd = ntohl(initack_cp->init.a_rwnd);
___
svn-src-head@freebsd.org 

svn commit: r368521 - head/libexec/tftpd

2020-12-10 Thread Michael Tuexen
Author: tuexen
Date: Thu Dec 10 19:36:33 2020
New Revision: 368521
URL: https://svnweb.freebsd.org/changeset/base/368521

Log:
  Fix the TFTP client when performing a RRQ for files smaller than 512 bytes
  and the server not sending an OACK:
  * Close the file.
  * Report the correct the number of received blocks.
  
  MFC after:1 week

Modified:
  head/libexec/tftpd/tftp-transfer.c

Modified: head/libexec/tftpd/tftp-transfer.c
==
--- head/libexec/tftpd/tftp-transfer.c  Thu Dec 10 18:34:15 2020
(r368520)
+++ head/libexec/tftpd/tftp-transfer.c  Thu Dec 10 19:36:33 2020
(r368521)
@@ -280,6 +280,8 @@ tftp_receive(int peer, uint16_t *block, struct tftp_st
}
 
if (fb_size != segsize) {
+   ts->blocks++;
+   write_close();
gettimeofday(&(ts->tstop), NULL);
return;
}
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r368394 - head/libexec/tftpd

2020-12-06 Thread Michael Tuexen
Author: tuexen
Date: Sun Dec  6 18:43:12 2020
New Revision: 368394
URL: https://svnweb.freebsd.org/changeset/base/368394

Log:
  When dropping packets (RRQ or WRQ) for debugging, report the send
  operation as successful. Reporting a failure stops the transfer
  instead of using timeouts.
  
  MFC after:1 week

Modified:
  head/libexec/tftpd/tftp-io.c

Modified: head/libexec/tftpd/tftp-io.c
==
--- head/libexec/tftpd/tftp-io.cSun Dec  6 18:09:14 2020
(r368393)
+++ head/libexec/tftpd/tftp-io.cSun Dec  6 18:43:12 2020
(r368394)
@@ -190,7 +190,7 @@ send_wrq(int peer, char *filename, char *mode)
filename, mode
);
 
-   DROPPACKETn("send_wrq", 1);
+   DROPPACKETn("send_wrq", 0);
 
tp = (struct tftphdr *)buf;
tp->th_opcode = htons((u_short)WRQ);
@@ -238,7 +238,7 @@ send_rrq(int peer, char *filename, char *mode)
filename, mode
);
 
-   DROPPACKETn("send_rrq", 1);
+   DROPPACKETn("send_rrq", 0);
 
tp = (struct tftphdr *)buf;
tp->th_opcode = htons((u_short)RRQ);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r368163 - in head: sbin/ifconfig sys/dev/if_wg sys/dev/if_wg/include sys/dev/if_wg/include/crypto sys/dev/if_wg/include/sys sys/dev/if_wg/include/zinc sys/dev/if_wg/module sys/dev/if_w

2020-11-30 Thread Michael Tuexen



> On 29. Nov 2020, at 20:38, Matt Macy  wrote:
> 
> Author: mmacy
> Date: Sun Nov 29 19:38:03 2020
> New Revision: 368163
> URL: https://svnweb.freebsd.org/changeset/base/368163
> 
> Log:
>  Import kernel WireGuard support
> 
>  Data path largely shared with the OpenBSD implementation by
>  Matt Dunwoodie 
> 
>  Reviewed by: gre...@freebsd.org
>  MFC after:   1 month
>  Sponsored by:Rubicon LLC, (Netgate)
>  Differential Revision:   https://reviews.freebsd.org/D26137
> 
Is there some documentation available somewhere how to setup a tunnel?

Best regards
Michael

___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r368167 - head/sys/dev/nvme

2020-11-30 Thread Michael Tuexen
> On 30. Nov 2020, at 08:01, Michal Meloun  wrote:
> 
> Author: mmel
> Date: Mon Nov 30 07:01:12 2020
> New Revision: 368167
> URL: https://svnweb.freebsd.org/changeset/base/368167
> 
> Log:
>  NVME: Don't try to swap data on little endian machines.
>  These swapping functions violate BUSDMA contract - we cannot write
>  to armed (by bus_dmamap_sync(PRE_..)) buffers. Remove them at least
>  from little endian machines until a better solution will be developed.
This breaks building libsysdecode on a little endian (amd64) system:

tuexen@cirrus:~/head/lib/libsysdecode % sudo make
Password:
env CPP="cpp" MK_PF="yes"  /bin/sh 
/usr/home/tuexen/head/lib/libsysdecode/mkioctls /usr/include > ioctl.c.tmp
if [ ! -e ioctl.c ] || ! cmp -s ioctl.c ioctl.c.tmp; then  mv -f ioctl.c.tmp 
ioctl.c;  fi
cc  -O2 -pipe -fno-common   
-I/usr/obj/usr/home/tuexen/head/amd64.amd64/lib/libsysdecode 
-I/usr/home/tuexen/head/sys -I/usr/home/tuexen/head/libexec/rtld-elf -DPF -g 
-MD  -MF.depend.ioctl.o -MTioctl.o -std=gnu99 -Wno-format-zero-length 
-fstack-protector-strong -Wsystem-headers -Werror -Wall -Wno-format-y2k -W 
-Wno-unused-parameter -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith 
-Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wshadow -Wunused-parameter 
-Wcast-align -Wchar-subscripts -Winline -Wnested-externs -Wredundant-decls 
-Wold-style-definition -Wno-pointer-sign -Wmissing-variable-declarations 
-Wthread-safety -Wno-empty-body -Wno-string-plus-int -Wno-unused-const-variable 
 -Qunused-arguments-c ioctl.c -o ioctl.o
In file included from ioctl.c:33:
In file included from /usr/home/tuexen/head/sys/./cam/scsi/scsi_pass.h:35:
In file included from /usr/home/tuexen/head/sys/cam/cam_ccb.h:46:
In file included from /usr/home/tuexen/head/sys/cam/nvme/nvme_all.h:33:
/usr/home/tuexen/head/sys/dev/nvme/nvme.h:1733:56: error: unused parameter 's' 
[-Werror,-Wunused-parameter]
voidnvme_completion_swapbytes(struct nvme_completion *s)
  ^
/usr/home/tuexen/head/sys/dev/nvme/nvme.h:1747:58: error: unused parameter 's' 
[-Werror,-Wunused-parameter]
voidnvme_power_state_swapbytes(struct nvme_power_state *s)
^
/usr/home/tuexen/head/sys/dev/nvme/nvme.h:1760:66: error: unused parameter 's' 
[-Werror,-Wunused-parameter]
voidnvme_controller_data_swapbytes(struct nvme_controller_data *s)
^
/usr/home/tuexen/head/sys/dev/nvme/nvme.h:1812:64: error: unused parameter 's' 
[-Werror,-Wunused-parameter]
voidnvme_namespace_data_swapbytes(struct nvme_namespace_data *s)
  ^
/usr/home/tuexen/head/sys/dev/nvme/nvme.h:1841:82: error: unused parameter 's' 
[-Werror,-Wunused-parameter]
voidnvme_error_information_entry_swapbytes(struct 
nvme_error_information_entry *s)

^
/usr/home/tuexen/head/sys/dev/nvme/nvme.h:1858:26: error: unused parameter 'p' 
[-Werror,-Wunused-parameter]
voidnvme_le128toh(void *p)
^
/usr/home/tuexen/head/sys/dev/nvme/nvme.h:1874:82: error: unused parameter 's' 
[-Werror,-Wunused-parameter]
voidnvme_health_information_page_swapbytes(struct 
nvme_health_information_page *s)

^
/usr/home/tuexen/head/sys/dev/nvme/nvme.h:1902:62: error: unused parameter 's' 
[-Werror,-Wunused-parameter]
voidnvme_firmware_page_swapbytes(struct nvme_firmware_page *s)
^
/usr/home/tuexen/head/sys/dev/nvme/nvme.h:1913:50: error: unused parameter 's' 
[-Werror,-Wunused-parameter]
voidnvme_ns_list_swapbytes(struct nvme_ns_list *s)
^
/usr/home/tuexen/head/sys/dev/nvme/nvme.h:1924:76: error: unused parameter 's' 
[-Werror,-Wunused-parameter]
voidnvme_command_effects_page_swapbytes(struct nvme_command_effects_page *s)
  ^
/usr/home/tuexen/head/sys/dev/nvme/nvme.h:1937:78: error: unused parameter 's' 
[-Werror,-Wunused-parameter]
voidnvme_res_notification_page_swapbytes(struct nvme_res_notification_page 
*s)

^
/usr/home/tuexen/head/sys/dev/nvme/nvme.h:1946:76: error: unused parameter 's' 
[-Werror,-Wunused-parameter]
voidnvme_sanitize_status_page_swapbytes(struct nvme_sanitize_status_page *s)
  ^
/usr/home/tuexen/head/sys/dev/nvme/nvme.h:1962:66: error: unused parameter 's' 
[-Werror,-Wunused-parameter]
voidintel_log_temp_stats_swapbytes(struct intel_log_temp_stats *s)
 

svn commit: r367946 - head/sys/netinet

2020-11-23 Thread Michael Tuexen
Author: tuexen
Date: Mon Nov 23 10:13:56 2020
New Revision: 367946
URL: https://svnweb.freebsd.org/changeset/base/367946

Log:
  Fix two occurences of a typo in a comment introduced in r367530.
  
  Reported by:  lstewart@
  MFC after:1 week
  Differential Revision:https://reviews.freebsd.org/D27148

Modified:
  head/sys/netinet/tcp_input.c
  head/sys/netinet/tcp_syncache.c

Modified: head/sys/netinet/tcp_input.c
==
--- head/sys/netinet/tcp_input.cMon Nov 23 04:39:29 2020
(r367945)
+++ head/sys/netinet/tcp_input.cMon Nov 23 10:13:56 2020
(r367946)
@@ -1695,7 +1695,7 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, stru
}
/*
 * If timestamps were not negotiated during SYN/ACK and a
-* segment without a timestamp is received, ignore the
+* segment with a timestamp is received, ignore the
 * timestamp and process the packet normally.
 * See section 3.2 of RFC 7323.
 */

Modified: head/sys/netinet/tcp_syncache.c
==
--- head/sys/netinet/tcp_syncache.c Mon Nov 23 04:39:29 2020
(r367945)
+++ head/sys/netinet/tcp_syncache.c Mon Nov 23 10:13:56 2020
(r367946)
@@ -1213,7 +1213,7 @@ syncache_expand(struct in_conninfo *inc, struct tcpopt
 
/*
 * If timestamps were not negotiated during SYN/ACK and a
-* segment without a timestamp is received, ignore the
+* segment with a timestamp is received, ignore the
 * timestamp and process the packet normally.
 * See section 3.2 of RFC 7323.
 */
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r367530 - in head/sys/netinet: . tcp_stacks

2020-11-20 Thread Michael Tuexen
On 20. Nov 2020, at 00:13, John Baldwin  wrote:
> 
> On 11/19/20 2:55 PM, John Baldwin wrote:
>> On 11/9/20 1:49 PM, Michael Tuexen wrote:
>>> Author: tuexen
>>> Date: Mon Nov  9 21:49:40 2020
>>> New Revision: 367530
>>> URL: https://svnweb.freebsd.org/changeset/base/367530
>>> 
>>> Log:
>>>  RFC 7323 specifies that:
>>>  * TCP segments without timestamps should be dropped when support for
>>>the timestamp option has been negotiated.
>>>  * TCP segments with timestamps should be processed normally if support
>>>for the timestamp option has not been negotiated.
>>>  This patch enforces the above.
>>> 
>>>  PR:250499
>>>  Reviewed by:   gnn, rrs
>>>  MFC after: 1 week
>>>  Sponsored by:  Netflix, Inc
>>>  Differential Revision: https://reviews.freebsd.org/D27148
>>> 
>>> Modified:
>>>  head/sys/netinet/tcp_input.c
>>>  head/sys/netinet/tcp_stacks/bbr.c
>>>  head/sys/netinet/tcp_stacks/rack.c
>>>  head/sys/netinet/tcp_syncache.c
>>>  head/sys/netinet/tcp_timewait.c
>>> 
>>> Modified: head/sys/netinet/tcp_timewait.c
>>> ==
>>> --- head/sys/netinet/tcp_timewait.c Mon Nov  9 21:19:17 2020
>>> (r367529)
>>> +++ head/sys/netinet/tcp_timewait.c Mon Nov  9 21:49:40 2020
>>> (r367530)
>>> @@ -376,7 +376,7 @@ tcp_twstart(struct tcpcb *tp)
>>>  * looking for a pcb in the listen state.  Returns 0 otherwise.
>>>  */
>>> int
>>> -tcp_twcheck(struct inpcb *inp, struct tcpopt *to __unused, struct tcphdr 
>>> *th,
>>> +tcp_twcheck(struct inpcb *inp, struct tcpopt *to, struct tcphdr *th,
>>> struct mbuf *m, int tlen)
>>> {
>>> struct tcptw *tw;
>>> @@ -410,6 +410,16 @@ tcp_twcheck(struct inpcb *inp, struct tcpopt *to __unu
>>>  */
>>> if (thflags & TH_RST)
>>> goto drop;
>>> +
>>> +   /*
>>> +* If timestamps were negotiated during SYN/ACK and a
>>> +* segment without a timestamp is received, silently drop
>>> +* the segment.
>>> +* See section 3.2 of RFC 7323.
>>> +*/
>>> +   if (((to->to_flags & TOF_TS) == 0) && (tw->t_recent != 0)) {
>>> +   goto drop;
>>> +   }
>> 
>> This causes an insta-panic with TOE because toe_4tuple_check() passes in a 
>> NULL
>> pointer for 'to'.  I'm working on a fix for that, but perhaps wait to MFC 
>> until
>> the fix is ready so they can be merged together?
>> 
>> That said, TOE only calls this in the case that it has gotten a new SYN, so I
>> wonder if it makes sense to apply this check on a new SYN.  For a new SYN,
>> shouldn't we not care if the new connection is using a different timestamp
>> option from the old connection?  The language in RFC 7323 3.2 is all about
>> segments on an existing connection, not segments from a new connection I 
>> think?
>> 
>> That is, I think we should perhaps move this check after the TH_SYN check so
>> that a mismatch doesn't prevent recycling?
> 
> Actually, we move the check below requiring TH_ACK, I think this would fix 
> the TOE
> case and also DTRT for plain SYNs for non-TOE:
Yes, I committed this in https://svnweb.freebsd.org/changeset/base/367891
and also added a comment and a KASSERT.
> 
> diff --git a/sys/netinet/tcp_timewait.c b/sys/netinet/tcp_timewait.c
> index c52eab956303..85f1ccbe40f9 100644
> --- a/sys/netinet/tcp_timewait.c
> +++ b/sys/netinet/tcp_timewait.c
> @@ -411,16 +411,6 @@ tcp_twcheck(struct inpcb *inp, struct tcpopt *to, struct 
> tcphdr *th,
>   if (thflags & TH_RST)
>   goto drop;
> 
> - /*
> -  * If timestamps were negotiated during SYN/ACK and a
> -  * segment without a timestamp is received, silently drop
> -  * the segment.
> -  * See section 3.2 of RFC 7323.
> -  */
> - if (((to->to_flags & TOF_TS) == 0) && (tw->t_recent != 0)) {
> - goto drop;
> - }
> -
> #if 0
> /* PAWS not needed at the moment */
>   /*
> @@ -455,6 +445,16 @@ tcp_twcheck(struct inpcb *inp, struct tcpopt *to, struct 
> tcphdr *th,
>   if ((thflags & TH_ACK) == 0)
>   goto drop;
> 
> + /*
> +  * If timestamps were negotiated during SYN/ACK and a
> +  * segment without a timestamp is receive

svn commit: r367891 - head/sys/netinet

2020-11-20 Thread Michael Tuexen
Author: tuexen
Date: Fri Nov 20 13:00:28 2020
New Revision: 367891
URL: https://svnweb.freebsd.org/changeset/base/367891

Log:
  Fix an issue I introuced in r367530: tcp_twcheck() can be called
  with to == NULL for SYN segments. So don't assume tp != NULL.
  Thanks to jhb@ for reporting and suggesting a fix.
  
  PR:   250499
  MFC after:1 week
  XMFC-with:r367530
  Sponsored by: Netflix, Inc.

Modified:
  head/sys/netinet/tcp_timewait.c

Modified: head/sys/netinet/tcp_timewait.c
==
--- head/sys/netinet/tcp_timewait.c Fri Nov 20 12:31:02 2020
(r367890)
+++ head/sys/netinet/tcp_timewait.c Fri Nov 20 13:00:28 2020
(r367891)
@@ -374,6 +374,7 @@ tcp_twstart(struct tcpcb *tp)
 /*
  * Returns 1 if the TIME_WAIT state was killed and we should start over,
  * looking for a pcb in the listen state.  Returns 0 otherwise.
+ * It be called with to == NULL only for pure SYN-segments.
  */
 int
 tcp_twcheck(struct inpcb *inp, struct tcpopt *to, struct tcphdr *th,
@@ -397,6 +398,8 @@ tcp_twcheck(struct inpcb *inp, struct tcpopt *to, stru
goto drop;
 
thflags = th->th_flags;
+   KASSERT(to != NULL || (thflags & (TH_SYN | TH_ACK)) == TH_SYN,
+   ("tcp_twcheck: called without options on a non-SYN segment"));
 
/*
 * NOTE: for FIN_WAIT_2 (to be added later),
@@ -411,16 +414,6 @@ tcp_twcheck(struct inpcb *inp, struct tcpopt *to, stru
if (thflags & TH_RST)
goto drop;
 
-   /*
-* If timestamps were negotiated during SYN/ACK and a
-* segment without a timestamp is received, silently drop
-* the segment.
-* See section 3.2 of RFC 7323.
-*/
-   if (((to->to_flags & TOF_TS) == 0) && (tw->t_recent != 0)) {
-   goto drop;
-   }
-
 #if 0
 /* PAWS not needed at the moment */
/*
@@ -454,6 +447,16 @@ tcp_twcheck(struct inpcb *inp, struct tcpopt *to, stru
 */
if ((thflags & TH_ACK) == 0)
goto drop;
+
+   /*
+* If timestamps were negotiated during SYN/ACK and a
+* segment without a timestamp is received, silently drop
+* the segment.
+* See section 3.2 of RFC 7323.
+*/
+   if (((to->to_flags & TOF_TS) == 0) && (tw->t_recent != 0)) {
+   goto drop;
+   }
 
/*
 * Reset the 2MSL timer if this is a duplicate FIN.
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r367530 - in head/sys/netinet: . tcp_stacks

2020-11-19 Thread Michael Tuexen



> On 20. Nov 2020, at 00:13, John Baldwin  wrote:
> 
> On 11/19/20 2:55 PM, John Baldwin wrote:
>> On 11/9/20 1:49 PM, Michael Tuexen wrote:
>>> Author: tuexen
>>> Date: Mon Nov  9 21:49:40 2020
>>> New Revision: 367530
>>> URL: https://svnweb.freebsd.org/changeset/base/367530
>>> 
>>> Log:
>>>  RFC 7323 specifies that:
>>>  * TCP segments without timestamps should be dropped when support for
>>>the timestamp option has been negotiated.
>>>  * TCP segments with timestamps should be processed normally if support
>>>for the timestamp option has not been negotiated.
>>>  This patch enforces the above.
>>> 
>>>  PR:250499
>>>  Reviewed by:   gnn, rrs
>>>  MFC after: 1 week
>>>  Sponsored by:  Netflix, Inc
>>>  Differential Revision: https://reviews.freebsd.org/D27148
>>> 
>>> Modified:
>>>  head/sys/netinet/tcp_input.c
>>>  head/sys/netinet/tcp_stacks/bbr.c
>>>  head/sys/netinet/tcp_stacks/rack.c
>>>  head/sys/netinet/tcp_syncache.c
>>>  head/sys/netinet/tcp_timewait.c
>>> 
>>> Modified: head/sys/netinet/tcp_timewait.c
>>> ==
>>> --- head/sys/netinet/tcp_timewait.c Mon Nov  9 21:19:17 2020
>>> (r367529)
>>> +++ head/sys/netinet/tcp_timewait.c Mon Nov  9 21:49:40 2020
>>> (r367530)
>>> @@ -376,7 +376,7 @@ tcp_twstart(struct tcpcb *tp)
>>>  * looking for a pcb in the listen state.  Returns 0 otherwise.
>>>  */
>>> int
>>> -tcp_twcheck(struct inpcb *inp, struct tcpopt *to __unused, struct tcphdr 
>>> *th,
>>> +tcp_twcheck(struct inpcb *inp, struct tcpopt *to, struct tcphdr *th,
>>> struct mbuf *m, int tlen)
>>> {
>>> struct tcptw *tw;
>>> @@ -410,6 +410,16 @@ tcp_twcheck(struct inpcb *inp, struct tcpopt *to __unu
>>>  */
>>> if (thflags & TH_RST)
>>> goto drop;
>>> +
>>> +   /*
>>> +* If timestamps were negotiated during SYN/ACK and a
>>> +* segment without a timestamp is received, silently drop
>>> +* the segment.
>>> +* See section 3.2 of RFC 7323.
>>> +*/
>>> +   if (((to->to_flags & TOF_TS) == 0) && (tw->t_recent != 0)) {
>>> +   goto drop;
>>> +   }
>> 
>> This causes an insta-panic with TOE because toe_4tuple_check() passes in a 
>> NULL
>> pointer for 'to'.  I'm working on a fix for that, but perhaps wait to MFC 
>> until
>> the fix is ready so they can be merged together?
>> 
>> That said, TOE only calls this in the case that it has gotten a new SYN, so I
>> wonder if it makes sense to apply this check on a new SYN.  For a new SYN,
>> shouldn't we not care if the new connection is using a different timestamp
>> option from the old connection?  The language in RFC 7323 3.2 is all about
>> segments on an existing connection, not segments from a new connection I 
>> think?
>> 
>> That is, I think we should perhaps move this check after the TH_SYN check so
>> that a mismatch doesn't prevent recycling?
> 
> Actually, we move the check below requiring TH_ACK, I think this would fix 
> the TOE
> case and also DTRT for plain SYNs for non-TOE:
Let me have a look tomorrow morning...

Best regards
Michael
> 
> diff --git a/sys/netinet/tcp_timewait.c b/sys/netinet/tcp_timewait.c
> index c52eab956303..85f1ccbe40f9 100644
> --- a/sys/netinet/tcp_timewait.c
> +++ b/sys/netinet/tcp_timewait.c
> @@ -411,16 +411,6 @@ tcp_twcheck(struct inpcb *inp, struct tcpopt *to, struct 
> tcphdr *th,
>   if (thflags & TH_RST)
>   goto drop;
> 
> - /*
> -  * If timestamps were negotiated during SYN/ACK and a
> -  * segment without a timestamp is received, silently drop
> -  * the segment.
> -  * See section 3.2 of RFC 7323.
> -  */
> - if (((to->to_flags & TOF_TS) == 0) && (tw->t_recent != 0)) {
> - goto drop;
> - }
> -
> #if 0
> /* PAWS not needed at the moment */
>   /*
> @@ -455,6 +445,16 @@ tcp_twcheck(struct inpcb *inp, struct tcpopt *to, struct 
> tcphdr *th,
>   if ((thflags & TH_ACK) == 0)
>   goto drop;
> 
> + /*
> +  * If timestamps were negotiated during SYN/ACK and a
> +  * segment without a timestamp is received, silently drop
> +  * the segment.
> +  * See section 3.2 of RFC 7323.
> +  */
> + if (((to->to_flags & TOF_TS) == 0) && (tw->t_recent != 0)) {
> + goto drop;
> + }
> +
>   /*
>* Reset the 2MSL timer if this is a duplicate FIN.
>*/
> 
> The commented out PAWS bits would also seem to not be relevant for SYN-only
> packets?  However, I'm less sure of if that bit should be moved later as
> well. (Or perhaps it should just be removed.  It has been #if 0'd since the
> timewait structure was first added back in 2003 by jlemon@)
> 
> -- 
> John Baldwin

___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r367530 - in head/sys/netinet: . tcp_stacks

2020-11-09 Thread Michael Tuexen
Author: tuexen
Date: Mon Nov  9 21:49:40 2020
New Revision: 367530
URL: https://svnweb.freebsd.org/changeset/base/367530

Log:
  RFC 7323 specifies that:
  * TCP segments without timestamps should be dropped when support for
the timestamp option has been negotiated.
  * TCP segments with timestamps should be processed normally if support
for the timestamp option has not been negotiated.
  This patch enforces the above.
  
  PR:   250499
  Reviewed by:  gnn, rrs
  MFC after:1 week
  Sponsored by: Netflix, Inc
  Differential Revision:https://reviews.freebsd.org/D27148

Modified:
  head/sys/netinet/tcp_input.c
  head/sys/netinet/tcp_stacks/bbr.c
  head/sys/netinet/tcp_stacks/rack.c
  head/sys/netinet/tcp_syncache.c
  head/sys/netinet/tcp_timewait.c

Modified: head/sys/netinet/tcp_input.c
==
--- head/sys/netinet/tcp_input.cMon Nov  9 21:19:17 2020
(r367529)
+++ head/sys/netinet/tcp_input.cMon Nov  9 21:49:40 2020
(r367530)
@@ -977,8 +977,8 @@ findpcb:
 * XXXRW: It may be time to rethink timewait locking.
 */
if (inp->inp_flags & INP_TIMEWAIT) {
-   if (thflags & TH_SYN)
-   tcp_dooptions(, optp, optlen, TO_SYN);
+   tcp_dooptions(, optp, optlen,
+   (thflags & TH_SYN) ? TO_SYN : 0);
/*
 * NB: tcp_twcheck unlocks the INP and frees the mbuf.
 */
@@ -1680,20 +1680,29 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, stru
}
 
/*
-* If timestamps were negotiated during SYN/ACK they should
-* appear on every segment during this session and vice versa.
+* If timestamps were negotiated during SYN/ACK and a
+* segment without a timestamp is received, silently drop
+* the segment.
+* See section 3.2 of RFC 7323.
 */
if ((tp->t_flags & TF_RCVD_TSTMP) && !(to.to_flags & TOF_TS)) {
if ((s = tcp_log_addrs(inc, th, NULL, NULL))) {
log(LOG_DEBUG, "%s; %s: Timestamp missing, "
-   "no action\n", s, __func__);
+   "segment silently dropped\n", s, __func__);
free(s, M_TCPLOG);
}
+   goto drop;
}
+   /*
+* If timestamps were not negotiated during SYN/ACK and a
+* segment without a timestamp is received, ignore the
+* timestamp and process the packet normally.
+* See section 3.2 of RFC 7323.
+*/
if (!(tp->t_flags & TF_RCVD_TSTMP) && (to.to_flags & TOF_TS)) {
if ((s = tcp_log_addrs(inc, th, NULL, NULL))) {
log(LOG_DEBUG, "%s; %s: Timestamp not expected, "
-   "no action\n", s, __func__);
+   "segment processed normally\n", s, __func__);
free(s, M_TCPLOG);
}
}

Modified: head/sys/netinet/tcp_stacks/bbr.c
==
--- head/sys/netinet/tcp_stacks/bbr.c   Mon Nov  9 21:19:17 2020
(r367529)
+++ head/sys/netinet/tcp_stacks/bbr.c   Mon Nov  9 21:49:40 2020
(r367530)
@@ -11430,12 +11430,6 @@ bbr_do_segment_nounlock(struct mbuf *m, struct tcphdr 
 #ifdef STATS
stats_voi_update_abs_ulong(tp->t_stats, VOI_TCP_FRWIN, tiwin);
 #endif
-   /*
-* Parse options on any incoming segment.
-*/
-   tcp_dooptions(, (u_char *)(th + 1),
-   (th->th_off << 2) - sizeof(struct tcphdr),
-   (thflags & TH_SYN) ? TO_SYN : 0);
 
if (m->m_flags & M_TSTMP) {
/* Prefer the hardware timestamp if present */
@@ -11458,6 +11452,23 @@ bbr_do_segment_nounlock(struct mbuf *m, struct tcphdr 
 * Ok just get the current time.
 */
bbr->r_ctl.rc_rcvtime = lcts = cts = tcp_get_usecs(>rc_tv);
+   }
+   /*
+* Parse options on any incoming segment.
+*/
+   tcp_dooptions(, (u_char *)(th + 1),
+   (th->th_off << 2) - sizeof(struct tcphdr),
+   (thflags & TH_SYN) ? TO_SYN : 0);
+
+   /*
+* If timestamps were negotiated during SYN/ACK and a
+* segment without a timestamp is received, silently drop
+* the segment.
+* See section 3.2 of RFC 7323.
+*/
+   if ((tp->t_flags & TF_RCVD_TSTMP) && !(to.to_flags & TOF_TS)) {
+   retval = 0;
+   goto done_with_input;
}
/*
 * If echoed timestamp is later than the current time, fall back to

Modified: head/sys/netinet/tcp_stacks/rack.c
==
--- head/sys/netinet/tcp_stacks/rack.c  Mon Nov  9 21:19:17 2020
(r367529)
+++ 

svn commit: r367520 - head/sys/netinet

2020-11-09 Thread Michael Tuexen
Author: tuexen
Date: Mon Nov  9 13:12:07 2020
New Revision: 367520
URL: https://svnweb.freebsd.org/changeset/base/367520

Log:
  Fix a potential use-after-free bug introduced in
  https://svnweb.freebsd.org/changeset/base/363046
  
  Thanks to Taylor Brandstetter for finding this issue using fuzz testing
  and reporting it in https://github.com/sctplab/usrsctp/issues/547

Modified:
  head/sys/netinet/sctp_indata.c

Modified: head/sys/netinet/sctp_indata.c
==
--- head/sys/netinet/sctp_indata.c  Mon Nov  9 09:31:21 2020
(r367519)
+++ head/sys/netinet/sctp_indata.c  Mon Nov  9 13:12:07 2020
(r367520)
@@ -5494,7 +5494,7 @@ sctp_handle_forward_tsn(struct sctp_tcb *stcb,
unsigned int i, fwd_sz, m_size;
uint32_t str_seq;
struct sctp_stream_in *strm;
-   struct sctp_queued_to_read *control, *sv;
+   struct sctp_queued_to_read *control, *ncontrol, *sv;
 
asoc = >asoc;
if ((fwd_sz = ntohs(fwd->ch.chunk_length)) < sizeof(struct 
sctp_forward_tsn_chunk)) {
@@ -5654,14 +5654,14 @@ sctp_handle_forward_tsn(struct sctp_tcb *stcb,
}
strm = >strmin[sid];
if (ordered) {
-   TAILQ_FOREACH(control, >inqueue, 
next_instrm) {
+   TAILQ_FOREACH_SAFE(control, >inqueue, 
next_instrm, ncontrol) {
if (SCTP_MID_GE(asoc->idata_supported, 
mid, control->mid)) {

sctp_flush_reassm_for_str_seq(stcb, asoc, strm, control, ordered, new_cum_tsn);
}
}
} else {
if (asoc->idata_supported) {
-   TAILQ_FOREACH(control, 
>uno_inqueue, next_instrm) {
+   TAILQ_FOREACH_SAFE(control, 
>uno_inqueue, next_instrm, ncontrol) {
if 
(SCTP_MID_GE(asoc->idata_supported, mid, control->mid)) {

sctp_flush_reassm_for_str_seq(stcb, asoc, strm, control, ordered, new_cum_tsn);
}
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r367464 - head/sys/kern

2020-11-07 Thread Michael Tuexen
Author: tuexen
Date: Sat Nov  7 21:17:49 2020
New Revision: 367464
URL: https://svnweb.freebsd.org/changeset/base/367464

Log:
  The ioctl() calls using FIONREAD, FIONWRITE, FIONSPACE, and SIOCATMARK
  access the socket send or receive buffer. This is not possible for
  listening sockets since r319722.
  Because send()/recv() calls fail on listening sockets, fail also ioctl()
  indicating EINVAL.
  
  PR:   250366
  Reported by:  Yong-Hao Zou
  Reviewed by:  glebius, rscheff
  MFC after:1 week
  Sponsored by: Netflix, Inc.
  Differential Revision:https://reviews.freebsd.org/D26897

Modified:
  head/sys/kern/sys_socket.c

Modified: head/sys/kern/sys_socket.c
==
--- head/sys/kern/sys_socket.c  Sat Nov  7 19:57:19 2020(r367463)
+++ head/sys/kern/sys_socket.c  Sat Nov  7 21:17:49 2020(r367464)
@@ -207,21 +207,34 @@ soo_ioctl(struct file *fp, u_long cmd, void *data, str
 
case FIONREAD:
/* Unlocked read. */
-   *(int *)data = sbavail(>so_rcv);
+   if (SOLISTENING(so)) {
+   error = EINVAL;
+   } else {
+   *(int *)data = sbavail(>so_rcv);
+   }
break;
 
case FIONWRITE:
/* Unlocked read. */
-   *(int *)data = sbavail(>so_snd);
+   if (SOLISTENING(so)) {
+   error = EINVAL;
+   } else {
+   *(int *)data = sbavail(>so_snd);
+   }
break;
 
case FIONSPACE:
/* Unlocked read. */
-   if ((so->so_snd.sb_hiwat < sbused(>so_snd)) ||
-   (so->so_snd.sb_mbmax < so->so_snd.sb_mbcnt))
-   *(int *)data = 0;
-   else
-   *(int *)data = sbspace(>so_snd);
+   if (SOLISTENING(so)) {
+   error = EINVAL;
+   } else {
+   if ((so->so_snd.sb_hiwat < sbused(>so_snd)) ||
+   (so->so_snd.sb_mbmax < so->so_snd.sb_mbcnt)) {
+   *(int *)data = 0;
+   } else {
+   *(int *)data = sbspace(>so_snd);
+   }
+   }
break;
 
case FIOSETOWN:
@@ -242,7 +255,11 @@ soo_ioctl(struct file *fp, u_long cmd, void *data, str
 
case SIOCATMARK:
/* Unlocked read. */
-   *(int *)data = (so->so_rcv.sb_state & SBS_RCVATMARK) != 0;
+   if (SOLISTENING(so)) {
+   error = EINVAL;
+   } else {
+   *(int *)data = (so->so_rcv.sb_state & SBS_RCVATMARK) != 
0;
+   }
break;
default:
/*
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r366750 - head/sys/netinet

2020-10-16 Thread Michael Tuexen
Author: tuexen
Date: Fri Oct 16 10:44:48 2020
New Revision: 366750
URL: https://svnweb.freebsd.org/changeset/base/366750

Log:
  Improve the handling of cookie life times.
  The staleness reported in an error cause is in us, not ms.
  Enforce limits on the life time via sysct; and socket options
  consistently. Update the description of the sysctl variable to
  use the right unit. Also do some minor cleanups.
  This also fixes an interger overflow issue if the peer can
  modify the cookie. This was reported by Felix Weinrank by fuzz testing
  the userland stack and in
  https://oss-fuzz.com/testcase-detail/4800394024452096
  
  MFC after:3 days

Modified:
  head/sys/netinet/sctp.h
  head/sys/netinet/sctp_input.c
  head/sys/netinet/sctp_output.c
  head/sys/netinet/sctp_sysctl.h
  head/sys/netinet/sctp_usrreq.c

Modified: head/sys/netinet/sctp.h
==
--- head/sys/netinet/sctp.h Fri Oct 16 10:10:09 2020(r366749)
+++ head/sys/netinet/sctp.h Fri Oct 16 10:44:48 2020(r366750)
@@ -599,6 +599,7 @@ struct sctp_error_auth_invalid_hmac {
  */
 #define SCTP_MAX_SACK_DELAY 500/* per RFC4960 */
 #define SCTP_MAX_HB_INTERVAL 1440  /* 4 hours in ms */
+#define SCTP_MIN_COOKIE_LIFE 1000  /* 1 second in ms */
 #define SCTP_MAX_COOKIE_LIFE  360  /* 1 hour in ms */
 
 /* Types of logging/KTR tracing  that can be enabled via the

Modified: head/sys/netinet/sctp_input.c
==
--- head/sys/netinet/sctp_input.c   Fri Oct 16 10:10:09 2020
(r366749)
+++ head/sys/netinet/sctp_input.c   Fri Oct 16 10:44:48 2020
(r366750)
@@ -1164,13 +1164,10 @@ sctp_handle_error(struct sctp_chunkhdr *ch,
struct sctp_error_stale_cookie *stale_cookie;
 
stale_cookie = (struct sctp_error_stale_cookie 
*)cause;
-   asoc->cookie_preserve_req = 
ntohl(stale_cookie->stale_time);
-   /* Double it to be more robust on RTX */
-   if (asoc->cookie_preserve_req <= UINT32_MAX / 
2) {
-   asoc->cookie_preserve_req *= 2;
-   } else {
-   asoc->cookie_preserve_req = UINT32_MAX;
-   }
+   /* stable_time is in usec, convert to msec. */
+   asoc->cookie_preserve_req = 
ntohl(stale_cookie->stale_time) / 1000;
+   /* Double it to be more robust on RTX. */
+   asoc->cookie_preserve_req *= 2;
asoc->stale_cookie_count++;
if (asoc->stale_cookie_count >
asoc->max_init_times) {
@@ -2254,7 +2251,7 @@ sctp_handle_cookie_echo(struct mbuf *m, int iphlen, in
unsigned int sig_offset, cookie_offset;
unsigned int cookie_len;
struct timeval now;
-   struct timeval time_expires;
+   struct timeval time_entered, time_expires;
int notification = 0;
struct sctp_nets *netl;
int had_a_existing_tcb = 0;
@@ -2382,13 +2379,30 @@ sctp_handle_cookie_echo(struct mbuf *m, int iphlen, in
return (NULL);
}
 
+   if (sctp_ticks_to_msecs(cookie->cookie_life) > SCTP_MAX_COOKIE_LIFE) {
+   SCTPDBG(SCTP_DEBUG_INPUT2, "handle_cookie_echo: Invalid cookie 
lifetime\n");
+   return (NULL);
+   }
+   time_entered.tv_sec = cookie->time_entered.tv_sec;
+   time_entered.tv_usec = cookie->time_entered.tv_usec;
+   if ((time_entered.tv_sec < 0) ||
+   (time_entered.tv_usec < 0) ||
+   (time_entered.tv_usec >= 100)) {
+   /* Invalid time stamp. Cookie must have been modified. */
+   SCTPDBG(SCTP_DEBUG_INPUT2, "handle_cookie_echo: Invalid time 
stamp\n");
+   return (NULL);
+   }
+   (void)SCTP_GETTIME_TIMEVAL();
+   if (timevalcmp(, _entered, <)) {
+   SCTPDBG(SCTP_DEBUG_INPUT2, "handle_cookie_echo: cookie 
generated in the future!\n");
+   return (NULL);
+   }
/*
-* check the cookie timestamps to be sure it's not stale
+* Check the cookie timestamps to be sure it's not stale.
+* cookie_life is in ticks, so we convert to seconds.
 */
-   (void)SCTP_GETTIME_TIMEVAL();
-   /* Expire time is in Ticks, so we convert to seconds */
-   time_expires.tv_sec = cookie->time_entered.tv_sec + 
sctp_ticks_to_secs(cookie->cookie_life);
-   time_expires.tv_usec = cookie->time_entered.tv_usec;
+   time_expires.tv_sec = time_entered.tv_sec + 
sctp_ticks_to_secs(cookie->cookie_life);
+   time_expires.tv_usec = time_entered.tv_usec;
if 

svn commit: r366517 - head/sys/netinet

2020-10-07 Thread Michael Tuexen
Author: tuexen
Date: Wed Oct  7 15:22:48 2020
New Revision: 366517
URL: https://svnweb.freebsd.org/changeset/base/366517

Log:
  Minor cleanups.
  
  MFC after:3 days

Modified:
  head/sys/netinet/sctp_cc_functions.c
  head/sys/netinet/sctp_output.c

Modified: head/sys/netinet/sctp_cc_functions.c
==
--- head/sys/netinet/sctp_cc_functions.cWed Oct  7 14:43:16 2020
(r366516)
+++ head/sys/netinet/sctp_cc_functions.cWed Oct  7 15:22:48 2020
(r366517)
@@ -1993,12 +1993,12 @@ htcp_alpha_update(struct htcp *ca)
scale = min(max(scale, 1U << 2), 10U << 3); /* clamping 
ratio to
 * interval 
[0.5,10]<<3 */
factor = (factor << 3) / scale;
-   if (!factor)
+   if (factor != 0)
factor = 1;
}
 
ca->alpha = 2 * factor * ((1 << 7) - ca->beta);
-   if (!ca->alpha)
+   if (ca->alpha != 0)
ca->alpha = ALPHA_BASE;
 }
 

Modified: head/sys/netinet/sctp_output.c
==
--- head/sys/netinet/sctp_output.c  Wed Oct  7 14:43:16 2020
(r366516)
+++ head/sys/netinet/sctp_output.c  Wed Oct  7 15:22:48 2020
(r366517)
@@ -2774,8 +2774,7 @@ sctp_select_nth_preferred_addr_from_ifn_boundall(struc
 uint8_t dest_is_priv,
 int addr_wanted,
 sa_family_t fam,
-sctp_route_t *ro
-)
+sctp_route_t *ro)
 {
struct sctp_ifa *ifa, *sifa;
int num_eligible_addr = 0;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r366489 - head/sys/netinet

2020-10-06 Thread Michael Tuexen
Author: tuexen
Date: Tue Oct  6 14:26:05 2020
New Revision: 366489
URL: https://svnweb.freebsd.org/changeset/base/366489

Log:
  Reset delayed SACK state when restarting an SCTP association.
  
  MFC after:3 days

Modified:
  head/sys/netinet/sctp_input.c

Modified: head/sys/netinet/sctp_input.c
==
--- head/sys/netinet/sctp_input.c   Tue Oct  6 14:03:59 2020
(r366488)
+++ head/sys/netinet/sctp_input.c   Tue Oct  6 14:26:05 2020
(r366489)
@@ -1830,17 +1830,14 @@ sctp_process_cookie_existing(struct mbuf *m, int iphle
/* move to OPEN state, if not in SHUTDOWN_SENT */
SCTP_SET_STATE(stcb, SCTP_STATE_OPEN);
}
-   asoc->pre_open_streams =
-   ntohs(initack_cp->init.num_outbound_streams);
+   asoc->pre_open_streams = 
ntohs(initack_cp->init.num_outbound_streams);
asoc->init_seq_number = ntohl(initack_cp->init.initial_tsn);
asoc->sending_seq = asoc->asconf_seq_out = 
asoc->str_reset_seq_out = asoc->init_seq_number;
asoc->asconf_seq_out_acked = asoc->asconf_seq_out - 1;
-
asoc->asconf_seq_in = asoc->last_acked_seq = 
asoc->init_seq_number - 1;
-
asoc->str_reset_seq_in = asoc->init_seq_number;
-
asoc->advanced_peer_ack_point = asoc->last_acked_seq;
+   asoc->send_sack = 1;
if (asoc->mapping_array) {
memset(asoc->mapping_array, 0,
asoc->mapping_array_size);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r366483 - head/sys/netinet

2020-10-06 Thread Michael Tuexen
Author: tuexen
Date: Tue Oct  6 11:29:08 2020
New Revision: 366483
URL: https://svnweb.freebsd.org/changeset/base/366483

Log:
  Ensure variables are initialized before used.
  
  MFC after:3 days

Modified:
  head/sys/netinet/sctp_input.c
  head/sys/netinet/sctp_pcb.c

Modified: head/sys/netinet/sctp_input.c
==
--- head/sys/netinet/sctp_input.c   Tue Oct  6 11:08:52 2020
(r366482)
+++ head/sys/netinet/sctp_input.c   Tue Oct  6 11:29:08 2020
(r366483)
@@ -5553,7 +5553,9 @@ sctp_common_input_processing(struct mbuf **mm, int iph
stcb = NULL;
goto out;
}
-   data_processed = 1;
+   if (retval == 0) {
+   data_processed = 1;
+   }
/*
 * Anything important needs to have been m_copy'ed in
 * process_data

Modified: head/sys/netinet/sctp_pcb.c
==
--- head/sys/netinet/sctp_pcb.c Tue Oct  6 11:08:52 2020(r366482)
+++ head/sys/netinet/sctp_pcb.c Tue Oct  6 11:29:08 2020(r366483)
@@ -6047,6 +6047,7 @@ sctp_load_addresses_from_init(struct sctp_tcb *stcb, s
peer_supports_prsctp = 0;
peer_supports_auth = 0;
peer_supports_asconf = 0;
+   peer_supports_asconf_ack = 0;
peer_supports_reconfig = 0;
peer_supports_nrsack = 0;
peer_supports_pktdrop = 0;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r366482 - head/sys/netinet

2020-10-06 Thread Michael Tuexen
Author: tuexen
Date: Tue Oct  6 11:08:52 2020
New Revision: 366482
URL: https://svnweb.freebsd.org/changeset/base/366482

Log:
  Remove dead stores reported by clang static code analysis
  
  MFC after:3 days

Modified:
  head/sys/netinet/sctp_input.c
  head/sys/netinet/sctp_output.c
  head/sys/netinet/sctp_pcb.c
  head/sys/netinet/sctputil.c

Modified: head/sys/netinet/sctp_input.c
==
--- head/sys/netinet/sctp_input.c   Tue Oct  6 10:51:47 2020
(r366481)
+++ head/sys/netinet/sctp_input.c   Tue Oct  6 11:08:52 2020
(r366482)
@@ -4116,7 +4116,6 @@ sctp_handle_packet_dropped(struct sctp_pktdrop_chunk *
struct sctp_idata_chunk *idata_chunk;
uint32_t bottle_bw, on_queue;
uint32_t offset, chk_len;
-   uint16_t trunc_len;
uint16_t pktdrp_len;
uint8_t pktdrp_flags;
 
@@ -4126,13 +4125,10 @@ sctp_handle_packet_dropped(struct sctp_pktdrop_chunk *
pktdrp_len = ntohs(cp->ch.chunk_length);
KASSERT(limit <= pktdrp_len, ("Inconsistent limit"));
if (pktdrp_flags & SCTP_PACKET_TRUNCATED) {
-   trunc_len = ntohs(cp->trunc_len);
-   if (trunc_len <= pktdrp_len - sizeof(struct 
sctp_pktdrop_chunk)) {
+   if (ntohs(cp->trunc_len) <= pktdrp_len - sizeof(struct 
sctp_pktdrop_chunk)) {
/* The peer plays games with us. */
return;
}
-   } else {
-   trunc_len = 0;
}
limit -= sizeof(struct sctp_pktdrop_chunk);
offset = 0;

Modified: head/sys/netinet/sctp_output.c
==
--- head/sys/netinet/sctp_output.c  Tue Oct  6 10:51:47 2020
(r366481)
+++ head/sys/netinet/sctp_output.c  Tue Oct  6 11:08:52 2020
(r366482)
@@ -8793,7 +8793,7 @@ no_data_fill:
 * the top of the for, but just to make sure
 * I will reset these again here.
 */
-   ctl_cnt = bundle_at = 0;
+   ctl_cnt = 0;
continue;   /* This takes us back to the
 * for() for the nets. */
} else {
@@ -9392,7 +9392,7 @@ sctp_chunk_retransmission(struct sctp_inpcb *inp,
uint32_t dmtu = 0;
 
SCTP_TCB_LOCK_ASSERT(stcb);
-   tmr_started = ctl_cnt = bundle_at = error = 0;
+   tmr_started = ctl_cnt = 0;
no_fragmentflg = 1;
fwd_tsn = 0;
*cnt_out = 0;

Modified: head/sys/netinet/sctp_pcb.c
==
--- head/sys/netinet/sctp_pcb.c Tue Oct  6 10:51:47 2020(r366481)
+++ head/sys/netinet/sctp_pcb.c Tue Oct  6 11:08:52 2020(r366482)
@@ -4345,7 +4345,7 @@ sctp_aloc_assoc(struct sctp_inpcb *inp, struct sockadd
LIST_INSERT_HEAD(head, stcb, sctp_asocs);
SCTP_INP_INFO_WUNLOCK();
 
-   if ((err = sctp_add_remote_addr(stcb, firstaddr, NULL, port, 
SCTP_DO_SETSCOPE, SCTP_ALLOC_ASOC))) {
+   if (sctp_add_remote_addr(stcb, firstaddr, NULL, port, SCTP_DO_SETSCOPE, 
SCTP_ALLOC_ASOC)) {
/* failure.. memory error? */
if (asoc->strmout) {
SCTP_FREE(asoc->strmout, SCTP_M_STRMO);

Modified: head/sys/netinet/sctputil.c
==
--- head/sys/netinet/sctputil.c Tue Oct  6 10:51:47 2020(r366481)
+++ head/sys/netinet/sctputil.c Tue Oct  6 11:08:52 2020(r366482)
@@ -1725,7 +1725,6 @@ sctp_timeout_handler(void *t)
net = (struct sctp_nets *)tmr->net;
CURVNET_SET((struct vnet *)tmr->vnet);
NET_EPOCH_ENTER(et);
-   did_output = 1;
released_asoc_reference = false;
 
 #ifdef SCTP_AUDITING_ENABLED
@@ -1994,7 +1993,6 @@ sctp_timeout_handler(void *t)
op_err = 
sctp_generate_cause(SCTP_BASE_SYSCTL(sctp_diag_info_code),
"Shutdown guard timer expired");
sctp_abort_an_association(inp, stcb, op_err, 
SCTP_SO_NOT_LOCKED);
-   did_output = true;
/* no need to unlock on tcb its gone */
goto out_decr;
case SCTP_TIMER_TYPE_AUTOCLOSE:
@@ -2071,7 +2069,6 @@ sctp_timeout_handler(void *t)
 #ifdef INVARIANTS
panic("Unknown timer type %d", type);
 #else
-   did_output = false;
goto out;
 #endif
}
@@ -2155,7 +2152,6 @@ sctp_timer_start(int t_type, struct sctp_inpcb *inp, s
("sctp_timer_start of type %d: inp = %p, stcb->sctp_ep %p",
t_type, stcb, stcb->sctp_ep));
tmr = NULL;
-   to_ticks = 0;
if (stcb != NULL) {
SCTP_TCB_LOCK_ASSERT(stcb);
  

svn commit: r366480 - head/sys/netinet

2020-10-06 Thread Michael Tuexen
Author: tuexen
Date: Tue Oct  6 10:41:04 2020
New Revision: 366480
URL: https://svnweb.freebsd.org/changeset/base/366480

Log:
  Cleanup, no functional change intended.
  
  MFC after:3 days

Modified:
  head/sys/netinet/sctp_usrreq.c

Modified: head/sys/netinet/sctp_usrreq.c
==
--- head/sys/netinet/sctp_usrreq.c  Tue Oct  6 10:41:00 2020
(r366479)
+++ head/sys/netinet/sctp_usrreq.c  Tue Oct  6 10:41:04 2020
(r366480)
@@ -3077,43 +3077,27 @@ flags_out:
break;
}
case SCTP_RECVRCVINFO:
-   {
-   int onoff;
-
-   if (*optsize < sizeof(int)) {
-   SCTP_LTRACE_ERR_RET(inp, NULL, NULL, 
SCTP_FROM_SCTP_USRREQ, EINVAL);
-   error = EINVAL;
-   } else {
-   SCTP_INP_RLOCK(inp);
-   onoff = sctp_is_feature_on(inp, 
SCTP_PCB_FLAGS_RECVRCVINFO);
-   SCTP_INP_RUNLOCK(inp);
-   }
-   if (error == 0) {
-   /* return the option value */
-   *(int *)optval = onoff;
-   *optsize = sizeof(int);
-   }
-   break;
+   if (*optsize < sizeof(int)) {
+   SCTP_LTRACE_ERR_RET(inp, NULL, NULL, 
SCTP_FROM_SCTP_USRREQ, EINVAL);
+   error = EINVAL;
+   } else {
+   SCTP_INP_RLOCK(inp);
+   *(int *)optval = sctp_is_feature_on(inp, 
SCTP_PCB_FLAGS_RECVRCVINFO);
+   SCTP_INP_RUNLOCK(inp);
+   *optsize = sizeof(int);
}
+   break;
case SCTP_RECVNXTINFO:
-   {
-   int onoff;
-
-   if (*optsize < sizeof(int)) {
-   SCTP_LTRACE_ERR_RET(inp, NULL, NULL, 
SCTP_FROM_SCTP_USRREQ, EINVAL);
-   error = EINVAL;
-   } else {
-   SCTP_INP_RLOCK(inp);
-   onoff = sctp_is_feature_on(inp, 
SCTP_PCB_FLAGS_RECVNXTINFO);
-   SCTP_INP_RUNLOCK(inp);
-   }
-   if (error == 0) {
-   /* return the option value */
-   *(int *)optval = onoff;
-   *optsize = sizeof(int);
-   }
-   break;
+   if (*optsize < sizeof(int)) {
+   SCTP_LTRACE_ERR_RET(inp, NULL, NULL, 
SCTP_FROM_SCTP_USRREQ, EINVAL);
+   error = EINVAL;
+   } else {
+   SCTP_INP_RLOCK(inp);
+   *(int *)optval = sctp_is_feature_on(inp, 
SCTP_PCB_FLAGS_RECVNXTINFO);
+   SCTP_INP_RUNLOCK(inp);
+   *optsize = sizeof(int);
}
+   break;
case SCTP_DEFAULT_SNDINFO:
{
struct sctp_sndinfo *info;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r366474 - head/sys/netinet

2020-10-06 Thread Michael Tuexen
Author: tuexen
Date: Tue Oct  6 09:51:40 2020
New Revision: 366474
URL: https://svnweb.freebsd.org/changeset/base/366474

Log:
  Whitespace changes.
  
  MFC after:3 days

Modified:
  head/sys/netinet/sctp_input.c

Modified: head/sys/netinet/sctp_input.c
==
--- head/sys/netinet/sctp_input.c   Tue Oct  6 09:28:24 2020
(r366473)
+++ head/sys/netinet/sctp_input.c   Tue Oct  6 09:51:40 2020
(r366474)
@@ -1510,7 +1510,7 @@ sctp_process_cookie_existing(struct mbuf *m, int iphle
 *   INIT-ACK(tag=t)-->
 *   INIT(tag=t)--> *1
 *   <---INIT-ACK(tag=a)---
- *   sctp_ep->sctp_flags & 
SCTP_PCB_FLAGS_TCPTYPE) ||
(stcb->sctp_ep->sctp_flags & 
SCTP_PCB_FLAGS_IN_TCPPOOL)) &&
(!SCTP_IS_LISTENING(inp))) {
-   stcb->sctp_ep->sctp_flags |=
-   SCTP_PCB_FLAGS_CONNECTED;
+   stcb->sctp_ep->sctp_flags |= 
SCTP_PCB_FLAGS_CONNECTED;
soisconnected(stcb->sctp_socket);
}
if (SCTP_GET_STATE(stcb) == SCTP_STATE_COOKIE_ECHOED)
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r366426 - head/sys/netinet

2020-10-04 Thread Michael Tuexen
Author: tuexen
Date: Sun Oct  4 15:37:34 2020
New Revision: 366426
URL: https://svnweb.freebsd.org/changeset/base/366426

Log:
  Use __func__ instead of __FUNCTION__ for consistency.
  
  MFC after:3 days

Modified:
  head/sys/netinet/sctp_bsd_addr.c
  head/sys/netinet/sctp_indata.c

Modified: head/sys/netinet/sctp_bsd_addr.c
==
--- head/sys/netinet/sctp_bsd_addr.cSun Oct  4 15:22:14 2020
(r366425)
+++ head/sys/netinet/sctp_bsd_addr.cSun Oct  4 15:37:34 2020
(r366426)
@@ -373,7 +373,7 @@ sctp_get_mbuf_for_msg(unsigned int space_needed, int w
m_freem(m);
return (NULL);
}
-   KASSERT(SCTP_BUF_NEXT(m) == NULL, ("%s: no chain allowed", 
__FUNCTION__));
+   KASSERT(SCTP_BUF_NEXT(m) == NULL, ("%s: no chain allowed", 
__func__));
}
 #ifdef SCTP_MBUF_LOGGING
if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MBUF_LOGGING_ENABLE) {

Modified: head/sys/netinet/sctp_indata.c
==
--- head/sys/netinet/sctp_indata.c  Sun Oct  4 15:22:14 2020
(r366425)
+++ head/sys/netinet/sctp_indata.c  Sun Oct  4 15:37:34 2020
(r366426)
@@ -301,7 +301,7 @@ sctp_mark_non_revokable(struct sctp_association *asoc,
SCTP_CALC_TSN_TO_GAP(gap, tsn, asoc->mapping_array_base_tsn);
in_r = SCTP_IS_TSN_PRESENT(asoc->mapping_array, gap);
in_nr = SCTP_IS_TSN_PRESENT(asoc->nr_mapping_array, gap);
-   KASSERT(in_r || in_nr, ("%s: Things are really messed up now", 
__FUNCTION__));
+   KASSERT(in_r || in_nr, ("%s: Things are really messed up now", 
__func__));
if (!in_nr) {
SCTP_SET_TSN_PRESENT(asoc->nr_mapping_array, gap);
if (SCTP_TSN_GT(tsn, asoc->highest_tsn_inside_nr_map)) {
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r366425 - head/sys/netinet

2020-10-04 Thread Michael Tuexen
Author: tuexen
Date: Sun Oct  4 15:22:14 2020
New Revision: 366425
URL: https://svnweb.freebsd.org/changeset/base/366425

Log:
  Cleanup, no functional change intended.
  
  MFC after:3 days

Modified:
  head/sys/netinet/sctp_indata.c

Modified: head/sys/netinet/sctp_indata.c
==
--- head/sys/netinet/sctp_indata.c  Sun Oct  4 13:24:58 2020
(r366424)
+++ head/sys/netinet/sctp_indata.c  Sun Oct  4 15:22:14 2020
(r366425)
@@ -285,17 +285,15 @@ sctp_build_ctl_nchunk(struct sctp_inpcb *inp, struct s
 static void
 sctp_mark_non_revokable(struct sctp_association *asoc, uint32_t tsn)
 {
-   uint32_t gap, i, cumackp1;
-   int fnd = 0;
-   int in_r = 0, in_nr = 0;
+   uint32_t gap, i;
+   int in_r, in_nr;
 
if (SCTP_BASE_SYSCTL(sctp_do_drain) == 0) {
return;
}
-   cumackp1 = asoc->cumulative_tsn + 1;
-   if (SCTP_TSN_GT(cumackp1, tsn)) {
+   if (SCTP_TSN_GE(asoc->cumulative_tsn, tsn)) {
/*
-* this tsn is behind the cum ack and thus we don't need to
+* This tsn is behind the cum ack and thus we don't need to
 * worry about it being moved from one to the other.
 */
return;
@@ -303,33 +301,27 @@ sctp_mark_non_revokable(struct sctp_association *asoc,
SCTP_CALC_TSN_TO_GAP(gap, tsn, asoc->mapping_array_base_tsn);
in_r = SCTP_IS_TSN_PRESENT(asoc->mapping_array, gap);
in_nr = SCTP_IS_TSN_PRESENT(asoc->nr_mapping_array, gap);
-   if ((in_r == 0) && (in_nr == 0)) {
-#ifdef INVARIANTS
-   panic("Things are really messed up now");
-#else
-   SCTP_PRINTF("gap:%x tsn:%x\n", gap, tsn);
-   sctp_print_mapping_array(asoc);
-#endif
-   }
-   if (in_nr == 0)
+   KASSERT(in_r || in_nr, ("%s: Things are really messed up now", 
__FUNCTION__));
+   if (!in_nr) {
SCTP_SET_TSN_PRESENT(asoc->nr_mapping_array, gap);
-   if (in_r)
-   SCTP_UNSET_TSN_PRESENT(asoc->mapping_array, gap);
-   if (SCTP_TSN_GT(tsn, asoc->highest_tsn_inside_nr_map)) {
-   asoc->highest_tsn_inside_nr_map = tsn;
+   if (SCTP_TSN_GT(tsn, asoc->highest_tsn_inside_nr_map)) {
+   asoc->highest_tsn_inside_nr_map = tsn;
+   }
}
-   if (tsn == asoc->highest_tsn_inside_map) {
-   /* We must back down to see what the new highest is */
-   for (i = tsn - 1; SCTP_TSN_GE(i, asoc->mapping_array_base_tsn); 
i--) {
-   SCTP_CALC_TSN_TO_GAP(gap, i, 
asoc->mapping_array_base_tsn);
-   if (SCTP_IS_TSN_PRESENT(asoc->mapping_array, gap)) {
-   asoc->highest_tsn_inside_map = i;
-   fnd = 1;
-   break;
+   if (in_r) {
+   SCTP_UNSET_TSN_PRESENT(asoc->mapping_array, gap);
+   if (tsn == asoc->highest_tsn_inside_map) {
+   /* We must back down to see what the new highest is. */
+   for (i = tsn - 1; SCTP_TSN_GE(i, 
asoc->mapping_array_base_tsn); i--) {
+   SCTP_CALC_TSN_TO_GAP(gap, i, 
asoc->mapping_array_base_tsn);
+   if (SCTP_IS_TSN_PRESENT(asoc->mapping_array, 
gap)) {
+   asoc->highest_tsn_inside_map = i;
+   break;
+   }
}
-   }
-   if (!fnd) {
-   asoc->highest_tsn_inside_map = 
asoc->mapping_array_base_tsn - 1;
+   if (!SCTP_TSN_GE(i, asoc->mapping_array_base_tsn)) {
+   asoc->highest_tsn_inside_map = 
asoc->mapping_array_base_tsn - 1;
+   }
}
}
 }
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r366340 - head/sys/kern

2020-10-01 Thread Michael Tuexen
> On 1. Oct 2020, at 21:17, Bryan Drewery  wrote:
> 
> Author: bdrewery
> Date: Thu Oct  1 19:17:03 2020
> New Revision: 366340
> URL: https://svnweb.freebsd.org/changeset/base/366340
> 
> Log:
>  Use unlocked page lookup for inmem() to avoid object lock contention
> 
>  Reviewed By: kib, markj
>  Sponsored by:Dell EMC Isilon
>  Submitted by:mlaier
>  Differential Revision:   https://reviews.freebsd.org/D26597
> 
> Modified:
>  head/sys/kern/vfs_bio.c
> 
> Modified: head/sys/kern/vfs_bio.c
> ==
> --- head/sys/kern/vfs_bio.c   Thu Oct  1 19:06:07 2020(r366339)
> +++ head/sys/kern/vfs_bio.c   Thu Oct  1 19:17:03 2020(r366340)
> @@ -154,7 +154,7 @@ caddr_t __read_mostly unmapped_buf;
> /* Used below and for softdep flushing threads in ufs/ffs/ffs_softdep.c */
> struct proc *bufdaemonproc;
> 
> -static int inmem(struct vnode *vp, daddr_t blkno);
> +static bool inmem(struct vnode *vp, daddr_t blkno);
> static void vm_hold_free_pages(struct buf *bp, int newbsize);
> static void vm_hold_load_pages(struct buf *bp, vm_offset_t from,
>   vm_offset_t to);
> @@ -3586,20 +3586,21 @@ incore(struct bufobj *bo, daddr_t blkno)
>  * it also hunts around in the VM system for the data.
>  */
> 
> -static int
> +static bool
> inmem(struct vnode * vp, daddr_t blkno)
> {
>   vm_object_t obj;
>   vm_offset_t toff, tinc, size;
> - vm_page_t m;
> + vm_page_t m, n;
>   vm_ooffset_t off;
> + int valid;
> 
>   ASSERT_VOP_LOCKED(vp, "inmem");
> 
>   if (incore(>v_bufobj, blkno))
> - return 1;
> + return (1);
>   if (vp->v_mount == NULL)
> - return 0;
> + return (0);
>   obj = vp->v_object;
>   if (obj == NULL)
>   return (0);
> @@ -3609,24 +3610,30 @@ inmem(struct vnode * vp, daddr_t blkno)
>   size = vp->v_mount->mnt_stat.f_iosize;
>   off = (vm_ooffset_t)blkno * 
> (vm_ooffset_t)vp->v_mount->mnt_stat.f_iosize;
> 
> - VM_OBJECT_RLOCK(obj);
>   for (toff = 0; toff < vp->v_mount->mnt_stat.f_iosize; toff += tinc) {
> - m = vm_page_lookup(obj, OFF_TO_IDX(off + toff));
> - if (!m)
> - goto notinmem;
> + m = vm_page_lookup_unlocked(obj, OFF_TO_IDX(off + toff));
> +recheck:
> + if (m == NULL)
> + return (0);
> + /*
> +  * Consider page validity only if page mapping didn't change
> +  * during the check.
> +  */
> + valid = vm_page_is_valid(m,
> + (vm_offset_t)((toff + off) & PAGE_MASK), tinc);
> + n = vm_page_lookup_unlocked(obj, OFF_TO_IDX(off + toff));
Where is vm_page_lookup_unlocked() defined? For me, this breaks kernel 
compilation...

Best regards
Michael
> + if (m != n) {
> + m = n;
> + goto recheck;
> + }
> + if (!valid)
> + return (0);
> +
>   tinc = size;
>   if (tinc > PAGE_SIZE - ((toff + off) & PAGE_MASK))
>   tinc = PAGE_SIZE - ((toff + off) & PAGE_MASK);
> - if (vm_page_is_valid(m,
> - (vm_offset_t) ((toff + off) & PAGE_MASK), tinc) == 0)
> - goto notinmem;
>   }
> - VM_OBJECT_RUNLOCK(obj);
> - return 1;
> -
> -notinmem:
> - VM_OBJECT_RUNLOCK(obj);
> - return (0);
> + return (1);
> }
> 
> /*



smime.p7s
Description: S/MIME cryptographic signature


svn commit: r366248 - head/sys/netinet

2020-09-29 Thread Michael Tuexen
Author: tuexen
Date: Tue Sep 29 09:36:06 2020
New Revision: 366248
URL: https://svnweb.freebsd.org/changeset/base/366248

Log:
  Improve the input validation and processing of cookies.
  This avoids setting the association in an inconsistent
  state, which could result in a use-after-free situation.
  This can be triggered by a malicious peer, if the peer
  can modify the cookie without the local endpoint recognizing
  it.
  Thanks to Ned Williamson for reporting the issue.
  
  MFC after:3 days

Modified:
  head/sys/netinet/sctp_input.c
  head/sys/netinet/sctp_pcb.c

Modified: head/sys/netinet/sctp_input.c
==
--- head/sys/netinet/sctp_input.c   Tue Sep 29 09:25:52 2020
(r366247)
+++ head/sys/netinet/sctp_input.c   Tue Sep 29 09:36:06 2020
(r366248)
@@ -2032,10 +2032,6 @@ sctp_process_cookie_new(struct mbuf *m, int iphlen, in
vrf_id, port);
return (NULL);
}
-   /* get the correct sctp_nets */
-   if (netp)
-   *netp = sctp_findnet(stcb, init_src);
-
asoc = >asoc;
/* get scope variables out of cookie */
asoc->scope.ipv4_local_scope = cookie->ipv4_scope;
@@ -2074,10 +2070,7 @@ sctp_process_cookie_new(struct mbuf *m, int iphlen, in
asoc->advanced_peer_ack_point = asoc->last_acked_seq;
 
/* process the INIT info (peer's info) */
-   if (netp)
-   retval = sctp_process_init(init_cp, stcb);
-   else
-   retval = 0;
+   retval = sctp_process_init(init_cp, stcb);
if (retval < 0) {
(void)sctp_free_assoc(inp, stcb, SCTP_NORMAL_PROC,
SCTP_FROM_SCTP_INPUT + SCTP_LOC_19);
@@ -2191,19 +2184,21 @@ sctp_process_cookie_new(struct mbuf *m, int iphlen, in
 */
;
}
-   /* since we did not send a HB make sure we don't double things */
-   if ((netp) && (*netp))
-   (*netp)->hb_responded = 1;
-
if (stcb->asoc.sctp_autoclose_ticks &&
sctp_is_feature_on(inp, SCTP_PCB_FLAGS_AUTOCLOSE)) {
sctp_timer_start(SCTP_TIMER_TYPE_AUTOCLOSE, inp, stcb, NULL);
}
(void)SCTP_GETTIME_TIMEVAL(>asoc.time_entered);
-   if ((netp != NULL) && (*netp != NULL)) {
+   *netp = sctp_findnet(stcb, init_src);
+   if (*netp != NULL) {
struct timeval old;
 
-   /* calculate the RTT and set the encaps port */
+   /*
+* Since we did not send a HB, make sure we don't double
+* things.
+*/
+   (*netp)->hb_responded = 1;
+   /* Calculate the RTT. */
old.tv_sec = cookie->time_entered.tv_sec;
old.tv_usec = cookie->time_entered.tv_usec;
sctp_calculate_rto(stcb, asoc, *netp, , 
SCTP_RTT_FROM_NON_DATA);

Modified: head/sys/netinet/sctp_pcb.c
==
--- head/sys/netinet/sctp_pcb.c Tue Sep 29 09:25:52 2020(r366247)
+++ head/sys/netinet/sctp_pcb.c Tue Sep 29 09:36:06 2020(r366248)
@@ -4242,7 +4242,9 @@ sctp_aloc_assoc(struct sctp_inpcb *inp, struct sockadd
if ((ntohs(sin->sin_port) == 0) ||
(sin->sin_addr.s_addr == INADDR_ANY) ||
(sin->sin_addr.s_addr == INADDR_BROADCAST) ||
-   IN_MULTICAST(ntohl(sin->sin_addr.s_addr))) {
+   IN_MULTICAST(ntohl(sin->sin_addr.s_addr)) ||
+   (((inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) != 0) 
&&
+   (SCTP_IPV6_V6ONLY(inp) != 0))) {
/* Invalid address */
SCTP_INP_RUNLOCK(inp);
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, 
SCTP_FROM_SCTP_PCB, EINVAL);
@@ -4261,7 +4263,8 @@ sctp_aloc_assoc(struct sctp_inpcb *inp, struct sockadd
sin6 = (struct sockaddr_in6 *)firstaddr;
if ((ntohs(sin6->sin6_port) == 0) ||
IN6_IS_ADDR_UNSPECIFIED(>sin6_addr) ||
-   IN6_IS_ADDR_MULTICAST(>sin6_addr)) {
+   IN6_IS_ADDR_MULTICAST(>sin6_addr) ||
+   ((inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) == 0)) 
{
/* Invalid address */
SCTP_INP_RUNLOCK(inp);
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, 
SCTP_FROM_SCTP_PCB, EINVAL);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r366226 - head/sys/netinet

2020-09-28 Thread Michael Tuexen
Author: tuexen
Date: Mon Sep 28 14:11:53 2020
New Revision: 366226
URL: https://svnweb.freebsd.org/changeset/base/366226

Log:
  Minor cleanup.
  
  MFC after:3 days

Modified:
  head/sys/netinet/sctp_pcb.c

Modified: head/sys/netinet/sctp_pcb.c
==
--- head/sys/netinet/sctp_pcb.c Mon Sep 28 13:56:35 2020(r366225)
+++ head/sys/netinet/sctp_pcb.c Mon Sep 28 14:11:53 2020(r366226)
@@ -6524,7 +6524,7 @@ sctp_load_addresses_from_init(struct sctp_tcb *stcb, s
(ptype == SCTP_DEL_IP_ADDRESS) ||
(ptype == SCTP_ERROR_CAUSE_IND) ||
(ptype == SCTP_SUCCESS_REPORT)) {
-/* don't care */ ;
+   /* don't care */
} else {
if ((ptype & 0x8000) == 0x) {
/*
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r366199 - head/sys/netinet

2020-09-27 Thread Michael Tuexen
Author: tuexen
Date: Sun Sep 27 13:32:02 2020
New Revision: 366199
URL: https://svnweb.freebsd.org/changeset/base/366199

Log:
  Cleanup, no functional change intended.
  
  MFC after:3 days

Modified:
  head/sys/netinet/sctp_indata.c

Modified: head/sys/netinet/sctp_indata.c
==
--- head/sys/netinet/sctp_indata.c  Sun Sep 27 13:24:01 2020
(r366198)
+++ head/sys/netinet/sctp_indata.c  Sun Sep 27 13:32:02 2020
(r366199)
@@ -5393,7 +5393,6 @@ sctp_flush_reassm_for_str_seq(struct sctp_tcb *stcb,
 struct sctp_queued_to_read *control, int ordered, uint32_t cumtsn)
 {
struct sctp_tmit_chunk *chk, *nchk;
-   int cnt_removed = 0;
 
/*
 * For now large messages held on the stream reasm that are complete
@@ -5410,12 +5409,11 @@ sctp_flush_reassm_for_str_seq(struct sctp_tcb *stcb,
}
TAILQ_FOREACH_SAFE(chk, >reasm, sctp_next, nchk) {
/* Purge hanging chunks */
-   if (!asoc->idata_supported && (ordered == 0)) {
+   if (!asoc->idata_supported && !ordered) {
if (SCTP_TSN_GT(chk->rec.data.tsn, cumtsn)) {
break;
}
}
-   cnt_removed++;
TAILQ_REMOVE(>reasm, chk, sctp_next);
if (asoc->size_on_reasm_queue >= chk->send_size) {
asoc->size_on_reasm_queue -= chk->send_size;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r366198 - head/sys/netinet

2020-09-27 Thread Michael Tuexen
Author: tuexen
Date: Sun Sep 27 13:24:01 2020
New Revision: 366198
URL: https://svnweb.freebsd.org/changeset/base/366198

Log:
  Improve the handling of receiving unordered and unreliable user
  messages using DATA chunks. Don't use fsn_included when not being
  sure that it is set to an appropriate value. If the default is
  used, which is -1, this can result in SCTP associaitons not
  making any user visible progress.
  
  Thanks to Yutaka Takeda for reporting this issue for the the
  userland stack in https://github.com/pion/sctp/issues/138.
  
  MFC after:3 days

Modified:
  head/sys/netinet/sctp_indata.c

Modified: head/sys/netinet/sctp_indata.c
==
--- head/sys/netinet/sctp_indata.c  Sun Sep 27 11:37:17 2020
(r366197)
+++ head/sys/netinet/sctp_indata.c  Sun Sep 27 13:24:01 2020
(r366198)
@@ -5403,7 +5403,9 @@ sctp_flush_reassm_for_str_seq(struct sctp_tcb *stcb,
 * it can be delivered... But for now we just dump everything on the
 * queue.
 */
-   if (!asoc->idata_supported && !ordered && 
SCTP_TSN_GT(control->fsn_included, cumtsn)) {
+   if (!asoc->idata_supported && !ordered &&
+   control->first_frag_seen &&
+   SCTP_TSN_GT(control->fsn_included, cumtsn)) {
return;
}
TAILQ_FOREACH_SAFE(chk, >reasm, sctp_next, nchk) {
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r366114 - head/sys/netinet

2020-09-24 Thread Michael Tuexen
Author: tuexen
Date: Thu Sep 24 12:26:06 2020
New Revision: 366114
URL: https://svnweb.freebsd.org/changeset/base/366114

Log:
  Whitespace changes.
  
  MFC after:3 days

Modified:
  head/sys/netinet/sctp_cc_functions.c
  head/sys/netinet/sctp_header.h
  head/sys/netinet/sctp_indata.c
  head/sys/netinet/sctp_lock_bsd.h
  head/sys/netinet/sctp_output.c
  head/sys/netinet/sctp_output.h
  head/sys/netinet/sctp_pcb.c
  head/sys/netinet/sctp_usrreq.c

Modified: head/sys/netinet/sctp_cc_functions.c
==
--- head/sys/netinet/sctp_cc_functions.cThu Sep 24 12:14:25 2020
(r366113)
+++ head/sys/netinet/sctp_cc_functions.cThu Sep 24 12:26:06 2020
(r366114)
@@ -1313,8 +1313,7 @@ sctp_cwnd_update_rtcc_after_ecn_echo(struct sctp_tcb *
sctp_cwnd_update_after_ecn_echo_common(stcb, net, in_window, 
num_pkt_lost, 1);
 }
 
-static
-void
+static void
 sctp_cwnd_update_rtcc_tsn_acknowledged(struct sctp_nets *net,
 struct sctp_tmit_chunk *tp1)
 {
@@ -1431,7 +1430,6 @@ sctp_set_rtcc_initial_cc_param(struct sctp_tcb *stcb,
net->cc_mod.rtcc.use_dccc_ecn = SCTP_BASE_SYSCTL(sctp_use_dccc_ecn);
net->cc_mod.rtcc.step_cnt = 0;
net->cc_mod.rtcc.last_step_state = 0;
-
 }
 
 static int
@@ -2041,7 +2039,7 @@ htcp_cong_avoid(struct sctp_tcb *stcb, struct sctp_net
 {
/*-
 * How to handle these functions?
- * if (!tcp_is_cwnd_limited(sk, in_flight)) RRS - good question.
+*  if (!tcp_is_cwnd_limited(sk, in_flight)) RRS - good question.
 *  return;
 */
if (net->cwnd <= net->ssthresh) {

Modified: head/sys/netinet/sctp_header.h
==
--- head/sys/netinet/sctp_header.h  Thu Sep 24 12:14:25 2020
(r366113)
+++ head/sys/netinet/sctp_header.h  Thu Sep 24 12:26:06 2020
(r366114)
@@ -530,41 +530,41 @@ struct sctp_auth_chunk {
 #ifndef SCTP_MAX_OVERHEAD
 #ifdef INET6
 #define SCTP_MAX_OVERHEAD (sizeof(struct sctp_data_chunk) + \
-  sizeof(struct sctphdr) + \
-  sizeof(struct sctp_ecne_chunk) + \
-  sizeof(struct sctp_sack_chunk) + \
-  sizeof(struct ip6_hdr))
+   sizeof(struct sctphdr) + \
+   sizeof(struct sctp_ecne_chunk) + \
+   sizeof(struct sctp_sack_chunk) + \
+   sizeof(struct ip6_hdr))
 
 #define SCTP_MED_OVERHEAD (sizeof(struct sctp_data_chunk) + \
-  sizeof(struct sctphdr) + \
-  sizeof(struct ip6_hdr))
+   sizeof(struct sctphdr) + \
+   sizeof(struct ip6_hdr))
 
 #define SCTP_MIN_OVERHEAD (sizeof(struct ip6_hdr) + \
-  sizeof(struct sctphdr))
+   sizeof(struct sctphdr))
 
 #else
 #define SCTP_MAX_OVERHEAD (sizeof(struct sctp_data_chunk) + \
-  sizeof(struct sctphdr) + \
-  sizeof(struct sctp_ecne_chunk) + \
-  sizeof(struct sctp_sack_chunk) + \
-  sizeof(struct ip))
+   sizeof(struct sctphdr) + \
+   sizeof(struct sctp_ecne_chunk) + \
+   sizeof(struct sctp_sack_chunk) + \
+   sizeof(struct ip))
 
 #define SCTP_MED_OVERHEAD (sizeof(struct sctp_data_chunk) + \
-  sizeof(struct sctphdr) + \
-  sizeof(struct ip))
+   sizeof(struct sctphdr) + \
+   sizeof(struct ip))
 
 #define SCTP_MIN_OVERHEAD (sizeof(struct ip) + \
-  sizeof(struct sctphdr))
+   sizeof(struct sctphdr))
 
 #endif /* INET6 */
 #endif /* !SCTP_MAX_OVERHEAD */
 
 #define SCTP_MED_V4_OVERHEAD (sizeof(struct sctp_data_chunk) + \
- sizeof(struct sctphdr) + \
- sizeof(struct ip))
+  sizeof(struct sctphdr) + \
+  sizeof(struct ip))
 
 #define SCTP_MIN_V4_OVERHEAD (sizeof(struct ip) + \
- sizeof(struct sctphdr))
+  sizeof(struct sctphdr))
 
 #undef SCTP_PACKED
 #endif /* !__sctp_header_h__ */

Modified: head/sys/netinet/sctp_indata.c
==
--- head/sys/netinet/sctp_indata.c  Thu Sep 24 12:14:25 2020
(r366113)
+++ head/sys/netinet/sctp_indata.c  Thu Sep 24 12:26:06 2020
(r366114)
@@ -2532,7 +2532,6 @@ sctp_slide_mapping_arrays(struct sctp_tcb *stcb)
 * 

svn commit: r365688 - head/usr.bin/netstat

2020-09-13 Thread Michael Tuexen
Author: tuexen
Date: Sun Sep 13 09:14:32 2020
New Revision: 365688
URL: https://svnweb.freebsd.org/changeset/base/365688

Log:
  Add a -C option to netstat to display the congestion control for
  TCP connections.
  
  Reviewed by:  rscheff
  MFC after:1 week
  Sponsored by: Netflix, Inc.
  Differential Revision:https://reviews.freebsd.org/D26414

Modified:
  head/usr.bin/netstat/inet.c
  head/usr.bin/netstat/main.c
  head/usr.bin/netstat/netstat.1
  head/usr.bin/netstat/netstat.h

Modified: head/usr.bin/netstat/inet.c
==
--- head/usr.bin/netstat/inet.c Sun Sep 13 09:12:25 2020(r365687)
+++ head/usr.bin/netstat/inet.c Sun Sep 13 09:14:32 2020(r365688)
@@ -341,6 +341,9 @@ protopr(u_long off, const char *name, int af1, int pro
xo_emit("  {T:/%8.8s} {T:/%5.5s}",
"flowid", "ftype");
}
+   if (Cflag)
+   xo_emit(" {T:/%-*.*s}", TCP_CA_NAME_MAX,
+   TCP_CA_NAME_MAX, "CC");
if (Pflag)
xo_emit(" {T:/%s}", "Log ID");
xo_emit("\n");
@@ -514,9 +517,15 @@ protopr(u_long off, const char *name, int af1, int pro
inp->inp_flowid,
inp->inp_flowtype);
}
-   if (istcp && Pflag)
-   xo_emit(" {:log-id/%s}", tp->xt_logid[0] == '\0' ?
-   "-" : tp->xt_logid);
+   if (istcp) {
+   if (Cflag)
+   xo_emit(" {:cc/%-*.*s}", TCP_CA_NAME_MAX,
+   TCP_CA_NAME_MAX, tp->xt_cc);
+   if (Pflag)
+   xo_emit(" {:log-id/%s}",
+   tp->xt_logid[0] == '\0' ?
+   "-" : tp->xt_logid);
+   }
xo_emit("\n");
xo_close_instance("socket");
}

Modified: head/usr.bin/netstat/main.c
==
--- head/usr.bin/netstat/main.c Sun Sep 13 09:12:25 2020(r365687)
+++ head/usr.bin/netstat/main.c Sun Sep 13 09:14:32 2020(r365688)
@@ -205,6 +205,7 @@ int Aflag;  /* show addresses of protocol control 
bloc
 intaflag;  /* show all sockets (including servers) */
 static int Bflag;  /* show information about bpf consumers */
 intbflag;  /* show i/f total bytes in/out */
+intCflag;  /* show congestion control */
 intdflag;  /* show i/f dropped packets */
 intgflag;  /* show group (multicast) routing or stats */
 inthflag;  /* show counters in human readable format */
@@ -249,7 +250,7 @@ main(int argc, char *argv[])
if (argc < 0)
exit(EXIT_FAILURE);
 
-   while ((ch = getopt(argc, argv, 
"46AaBbdF:f:ghI:iLlM:mN:noPp:Qq:RrSTsuWw:xz"))
+   while ((ch = getopt(argc, argv, 
"46AaBbCdF:f:ghI:iLlM:mN:noPp:Qq:RrSTsuWw:xz"))
!= -1)
switch(ch) {
case '4':
@@ -277,6 +278,9 @@ main(int argc, char *argv[])
break;
case 'b':
bflag = 1;
+   break;
+   case 'C':
+   Cflag = 1;
break;
case 'd':
dflag = 1;

Modified: head/usr.bin/netstat/netstat.1
==
--- head/usr.bin/netstat/netstat.1  Sun Sep 13 09:12:25 2020
(r365687)
+++ head/usr.bin/netstat/netstat.1  Sun Sep 13 09:14:32 2020
(r365688)
@@ -28,7 +28,7 @@
 .\"@(#)netstat.1   8.8 (Berkeley) 4/18/94
 .\" $FreeBSD$
 .\"
-.Dd July 21, 2020
+.Dd September 13, 2020
 .Dt NETSTAT 1
 .Os
 .Sh NAME
@@ -39,7 +39,7 @@
 .Bl -tag -width "netstat"
 .It Nm
 .Op Fl -libxo
-.Op Fl 46AaLnPRSTWx
+.Op Fl 46AaCLnPRSTWx
 .Op Fl f Ar protocol_family | Fl p Ar protocol
 .Op Fl M Ar core
 .Op Fl N Ar system
@@ -111,7 +111,7 @@ depending on the options for the information presented
 .It Xo
 .Bk -words
 .Nm
-.Op Fl 46AaLnRSTWx
+.Op Fl 46AaCLnRSTWx
 .Op Fl f Ar protocol_family | Fl p Ar protocol
 .Op Fl M Ar core
 .Op Fl N Ar system
@@ -172,6 +172,8 @@ associated with a socket; used for debugging.
 .It Fl a
 Show the state of all sockets;
 normally sockets used by server processes are not shown.
+.It Fl C
+Show the congestion control of TCP sockets.
 .It Fl L
 Show the size of the various listen queues.
 The first count shows the number of unaccepted connections,

Modified: head/usr.bin/netstat/netstat.h
==
--- 

svn commit: r365687 - head/usr.bin/sockstat

2020-09-13 Thread Michael Tuexen
Author: tuexen
Date: Sun Sep 13 09:12:25 2020
New Revision: 365687
URL: https://svnweb.freebsd.org/changeset/base/365687

Log:
  Add a -C option to sockstat to display the congestion control for TCP
  connections.
  
  Reviewed by:  rscheff
  MFC after:1 week
  Sponsored by: Netflix, Inc.
  Differential Revision:https://reviews.freebsd.org/D26413

Modified:
  head/usr.bin/sockstat/sockstat.1
  head/usr.bin/sockstat/sockstat.c

Modified: head/usr.bin/sockstat/sockstat.1
==
--- head/usr.bin/sockstat/sockstat.1Sun Sep 13 09:06:50 2020
(r365686)
+++ head/usr.bin/sockstat/sockstat.1Sun Sep 13 09:12:25 2020
(r365687)
@@ -27,7 +27,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd June 13, 2020
+.Dd September 13, 2020
 .Dt SOCKSTAT 1
 .Os
 .Sh NAME
@@ -35,7 +35,7 @@
 .Nd list open sockets
 .Sh SYNOPSIS
 .Nm
-.Op Fl 46cLlSsUuvw
+.Op Fl 46CcLlSsUuvw
 .Op Fl j Ar jid
 .Op Fl p Ar ports
 .Op Fl P Ar protocols
@@ -56,6 +56,9 @@ Show
 Show
 .Dv AF_INET6
 (IPv6) sockets.
+.It Fl C
+Display the congestion control module, if applicable.
+This is currently only implemented for TCP.
 .It Fl c
 Show connected sockets.
 .It Fl j Ar jail
@@ -170,6 +173,10 @@ is specified (only for SCTP or TCP).
 .It Li STACK
 The protocol stack if
 .Fl S
+is specified (only for TCP).
+.It Li CC
+The congestion control if
+.Fl C
 is specified (only for TCP).
 .El
 .Pp

Modified: head/usr.bin/sockstat/sockstat.c
==
--- head/usr.bin/sockstat/sockstat.cSun Sep 13 09:06:50 2020
(r365686)
+++ head/usr.bin/sockstat/sockstat.cSun Sep 13 09:12:25 2020
(r365687)
@@ -74,6 +74,7 @@ __FBSDID("$FreeBSD$");
 
 static int  opt_4; /* Show IPv4 sockets */
 static int  opt_6; /* Show IPv6 sockets */
+static int  opt_C; /* Show congestion control */
 static int  opt_c; /* Show connected sockets */
 static int  opt_j; /* Show specified jail */
 static int  opt_L; /* Don't show IPv4 or IPv6 loopback sockets */
@@ -118,6 +119,7 @@ struct sock {
int state;
const char *protoname;
char stack[TCP_FUNCTION_NAME_LEN_MAX];
+   char cc[TCP_CA_NAME_MAX];
struct addr *laddr;
struct addr *faddr;
struct sock *next;
@@ -716,6 +718,7 @@ gather_inet(int proto)
sock->state = xtp->t_state;
memcpy(sock->stack, xtp->xt_stack,
TCP_FUNCTION_NAME_LEN_MAX);
+   memcpy(sock->cc, xtp->xt_cc, TCP_CA_NAME_MAX);
}
sock->protoname = protoname;
hash = (int)((uintptr_t)sock->socket % HASHSIZE);
@@ -1130,12 +1133,24 @@ displaysock(struct sock *s, int pos)
}
offset += 13;
}
-   if (opt_S && s->proto == IPPROTO_TCP) {
-   while (pos < offset)
-   pos += xprintf(" ");
-   xprintf("%.*s", TCP_FUNCTION_NAME_LEN_MAX,
-   s->stack);
+   if (opt_S) {
+   if (s->proto == IPPROTO_TCP) {
+   while (pos < offset)
+   pos += xprintf(" ");
+   pos += xprintf("%.*s",
+   TCP_FUNCTION_NAME_LEN_MAX,
+   s->stack);
+   }
+   offset += TCP_FUNCTION_NAME_LEN_MAX + 1;
}
+   if (opt_C) {
+   if (s->proto == IPPROTO_TCP) {
+   while (pos < offset)
+   pos += xprintf(" ");
+   xprintf("%.*s", TCP_CA_NAME_MAX, s->cc);
+   }
+   offset += TCP_CA_NAME_MAX + 1;
+   }
}
if (laddr != NULL)
laddr = laddr->next;
@@ -1170,7 +1185,10 @@ display(void)
printf(" %-12s", "CONN STATE");
}
if (opt_S)
-   printf(" %.*s", TCP_FUNCTION_NAME_LEN_MAX, "STACK");
+   printf(" %-*.*s", TCP_FUNCTION_NAME_LEN_MAX,
+   TCP_FUNCTION_NAME_LEN_MAX, "STACK");
+   if (opt_C)
+   printf(" %-.*s", TCP_CA_NAME_MAX, "CC");
printf("\n");
}
setpassent(1);
@@ -1286,13 +1304,16 @@ main(int argc, char *argv[])
int o, i;
 
opt_j = -1;
-   while 

svn commit: r365686 - head/sys/netinet

2020-09-13 Thread Michael Tuexen
Author: tuexen
Date: Sun Sep 13 09:06:50 2020
New Revision: 365686
URL: https://svnweb.freebsd.org/changeset/base/365686

Log:
  Export the name of the congestion control. This will be used by sockstat
  and netstat.
  
  Reviewed by:  rscheff
  MFC after:1 week
  Sponsored by: Netflix, Inc.
  Differential Revision:https://reviews.freebsd.org/D26412

Modified:
  head/sys/netinet/tcp_subr.c
  head/sys/netinet/tcp_var.h

Modified: head/sys/netinet/tcp_subr.c
==
--- head/sys/netinet/tcp_subr.c Sun Sep 13 09:00:00 2020(r365685)
+++ head/sys/netinet/tcp_subr.c Sun Sep 13 09:06:50 2020(r365686)
@@ -3457,6 +3457,8 @@ tcp_inptoxtp(const struct inpcb *inp, struct xtcpcb *x
 
bcopy(tp->t_fb->tfb_tcp_block_name, xt->xt_stack,
TCP_FUNCTION_NAME_LEN_MAX);
+   bcopy(CC_ALGO(tp)->name, xt->xt_cc,
+   TCP_CA_NAME_MAX);
 #ifdef TCP_BLACKBOX
(void)tcp_log_get_id(tp, xt->xt_logid);
 #endif

Modified: head/sys/netinet/tcp_var.h
==
--- head/sys/netinet/tcp_var.h  Sun Sep 13 09:00:00 2020(r365685)
+++ head/sys/netinet/tcp_var.h  Sun Sep 13 09:06:50 2020(r365686)
@@ -754,7 +754,8 @@ struct xtcpcb {
struct xinpcb   xt_inp;
charxt_stack[TCP_FUNCTION_NAME_LEN_MAX];/* (s) */
charxt_logid[TCP_LOG_ID_LEN];   /* (s) */
-   int64_t spare64[8];
+   charxt_cc[TCP_CA_NAME_MAX]; /* (s) */
+   int64_t spare64[6];
int32_t t_state;/* (s,p) */
uint32_tt_flags;/* (s,p) */
int32_t t_sndzerowin;   /* (s) */
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r365685 - head/usr.sbin/traceroute6

2020-09-13 Thread Michael Tuexen
Author: tuexen
Date: Sun Sep 13 09:00:00 2020
New Revision: 365685
URL: https://svnweb.freebsd.org/changeset/base/365685

Log:
  Add a -t option to traceroute6 to control the traffic class used when
  sending probe packets.
  
  Reviewed by:  rscheff
  MFC after:1 week
  Sponsored by: Netflix, Inc.
  Differential Revision:https://reviews.freebsd.org/D26410

Modified:
  head/usr.sbin/traceroute6/traceroute6.8
  head/usr.sbin/traceroute6/traceroute6.c

Modified: head/usr.sbin/traceroute6/traceroute6.8
==
--- head/usr.sbin/traceroute6/traceroute6.8 Sun Sep 13 02:17:57 2020
(r365684)
+++ head/usr.sbin/traceroute6/traceroute6.8 Sun Sep 13 09:00:00 2020
(r365685)
@@ -29,7 +29,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd July 16, 2019
+.Dd September 13, 2020
 .Dt TRACEROUTE6 8
 .Os
 .\"
@@ -61,6 +61,9 @@
 .Op Fl s Ar src
 .Ek
 .Bk -words
+.Op Fl t Ar tclass
+.Ek
+.Bk -words
 .Op Fl w Ar waittime
 .Ek
 .Bk -words
@@ -148,6 +151,13 @@ If
 .Ar datalen
 is up to 28, probe packets consist of a SHUTDOWN-ACK chunk possibly bundled
 with a PAD chunk. For larger probe packets, an INIT chunk is used.
+.It Fl t Ar tclass
+.Ar tclass
+specifies the
+.Em traffic class
+used when sending probe packets.
+The value must be a decimal integer in the range 0 to 255.
+The default is 0.
 .It Fl T
 Use TCP segments for the probes.
 .It Fl U

Modified: head/usr.sbin/traceroute6/traceroute6.c
==
--- head/usr.sbin/traceroute6/traceroute6.c Sun Sep 13 02:17:57 2020
(r365684)
+++ head/usr.sbin/traceroute6/traceroute6.c Sun Sep 13 09:00:00 2020
(r365685)
@@ -346,6 +346,7 @@ static u_long max_hops = 30;
 static u_int16_t srcport;
 static u_int16_t port = 32768+666; /* start udp dest port # for probe 
packets */
 static u_int16_t ident;
+static int tclass = -1;
 static int options;/* socket options */
 static int verbose;
 static int waittime = 5;   /* time to wait for response (in 
seconds) */
@@ -364,7 +365,7 @@ main(int argc, char *argv[])
int ch, i, on = 1, seq, rcvcmsglen, error;
struct addrinfo hints, *res;
static u_char *rcvcmsgbuf;
-   u_long probe, hops, lport;
+   u_long probe, hops, lport, ltclass;
struct hostent *hp;
size_t size, minlen;
uid_t uid;
@@ -414,7 +415,7 @@ main(int argc, char *argv[])
seq = 0;
ident = htons(getpid() & 0x); /* same as ping6 */
 
-   while ((ch = getopt(argc, argv, "aA:df:g:Ilm:nNp:q:rs:STUvw:")) != -1)
+   while ((ch = getopt(argc, argv, "aA:df:g:Ilm:nNp:q:rs:St:TUvw:")) != -1)
switch (ch) {
case 'a':
as_path = 1;
@@ -531,6 +532,17 @@ main(int argc, char *argv[])
case 'S':
useproto = IPPROTO_SCTP;
break;
+   case 't':
+   ep = NULL;
+   errno = 0;
+   ltclass = strtoul(optarg, , 0);
+   if (errno || !*optarg || *ep || ltclass > 255) {
+   fprintf(stderr,
+   "traceroute6: invalid traffic class.\n");
+   exit(1);
+   }
+   tclass = (int)ltclass;
+   break;
case 'T':
useproto = IPPROTO_TCP;
break;
@@ -595,6 +607,13 @@ main(int argc, char *argv[])
exit(1);
}
 
+   if (tclass != -1) {
+   if (setsockopt(sndsock, IPPROTO_IPV6, IPV6_TCLASS, ,
+   sizeof(int)) == -1) {
+   perror("setsockopt(IPV6_TCLASS)");
+   exit(7);
+   }
+   }
 
if (argc < 1 || argc > 2)
usage();
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r365658 - head/usr.sbin/traceroute6

2020-09-12 Thread Michael Tuexen
Author: tuexen
Date: Sat Sep 12 11:24:36 2020
New Revision: 365658
URL: https://svnweb.freebsd.org/changeset/base/365658

Log:
  Fix the length of probe packets when using UDP.
  Since https://svnweb.freebsd.org/changeset/base/365378 a raw socket is
  used for sending UDP probe packets instead of a UDP socket. So don't
  compensate for the UDP header anymore.

Modified:
  head/usr.sbin/traceroute6/traceroute6.c

Modified: head/usr.sbin/traceroute6/traceroute6.c
==
--- head/usr.sbin/traceroute6/traceroute6.c Sat Sep 12 11:19:54 2020
(r365657)
+++ head/usr.sbin/traceroute6/traceroute6.c Sat Sep 12 11:24:36 2020
(r365658)
@@ -677,8 +677,6 @@ main(int argc, char *argv[])
minlen, MAXPACKET);
exit(1);
}
-   if (useproto == IPPROTO_UDP)
-   datalen -= sizeof(struct udphdr);
if ((useproto == IPPROTO_SCTP) && (datalen & 3)) {
fprintf(stderr, 
"traceroute6: packet size must be a multiple of 4.\n");
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r365657 - head/usr.sbin/traceroute6

2020-09-12 Thread Michael Tuexen
Author: tuexen
Date: Sat Sep 12 11:19:54 2020
New Revision: 365657
URL: https://svnweb.freebsd.org/changeset/base/365657

Log:
  Simplify code, no functional change.
  
  Since https://svnweb.freebsd.org/base?view=revision=365378
  UDP is handled the same way as SCTP and TCP (using a raw socket).
  Therefore use the same code path.

Modified:
  head/usr.sbin/traceroute6/traceroute6.c

Modified: head/usr.sbin/traceroute6/traceroute6.c
==
--- head/usr.sbin/traceroute6/traceroute6.c Sat Sep 12 09:47:58 2020
(r365656)
+++ head/usr.sbin/traceroute6/traceroute6.c Sat Sep 12 11:19:54 2020
(r365657)
@@ -568,15 +568,10 @@ main(int argc, char *argv[])
case IPPROTO_ICMPV6:
sndsock = rcvsock;
break;
-   case IPPROTO_UDP:
-   if ((sndsock = socket(AF_INET6, SOCK_RAW, IPPROTO_UDP)) < 0) {
-   perror("socket(SOCK_RAW)");
-   exit(5);
-   }
-   break;
case IPPROTO_NONE:
case IPPROTO_SCTP:
case IPPROTO_TCP:
+   case IPPROTO_UDP:
if ((sndsock = socket(AF_INET6, SOCK_RAW, useproto)) < 0) {
perror("socket(SOCK_RAW)");
exit(5);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r365071 - in head/sys: net net/altq net/route net80211 netgraph netgraph/atm netgraph/atm/ccatm netgraph/atm/sscfu netgraph/atm/sscop netgraph/atm/uni netgraph/bluetooth/common netgrap

2020-09-02 Thread Michael Tuexen
> On 2. Sep 2020, at 20:28, Pedro Giffuni  wrote:
> 
> 
> On 02/09/2020 13:06, Alexey Dokuchaev wrote:
>> On Wed, Sep 02, 2020 at 10:18:15AM -0500, Pedro Giffuni wrote:
>>> On 01/09/2020 21:05, Alexey Dokuchaev wrote:
 ...
 This is common sense.  I can't count how often I wanted to hack on
 something in the base/kernel and was turned away by this atrocious
 excessive whitespace mess.
 
 Thank you Mateusz for cleaning this up.
>>> I honestly don't care much, but spaces do no harm and can make the code
>>> more readable. Sort of a silent comment, or what you do in written
>>> language when you start a new paragraph.
>> Right, but that's the example of appropriate usage of whitespace.  I was
>> talking about *excessive* whitespace, that is, more than two \n's in a row
>> if we speak of newlines (subject of these commits).
> 
> But how much space is rather subjective so Michael is right in asking what 
> rule has been violated.
> 
> No one is asking for the change to be reverted: the damage, if any, is 
> already done.
Just to be clear: I have NOT asked for reverting, I did not mentioned it.

I want to understand which rules have to be followed (and why).
The why was explained: Some developers don't work on files which violate
whitespace rules.

I just want to know the rules. Without knowing them, I can't follow them...

Best regards
Michael
> 
> Pedro.
> 
> 
>> ./danfe



smime.p7s
Description: S/MIME cryptographic signature


Re: svn commit: r365071 - in head/sys: net net/altq net/route net80211 netgraph netgraph/atm netgraph/atm/ccatm netgraph/atm/sscfu netgraph/atm/sscop netgraph/atm/uni netgraph/bluetooth/common netgrap

2020-09-02 Thread Michael Tuexen
> On 2. Sep 2020, at 04:05, Alexey Dokuchaev  wrote:
> 
> On Wed, Sep 02, 2020 at 12:41:43AM +0200, Michael Tuexen wrote:
>>> On 1. Sep 2020, at 23:19, Mateusz Guzik  wrote:
>>> Author: mjg
>>> Date: Tue Sep  1 21:19:14 2020
>>> New Revision: 365071
>>> URL: https://svnweb.freebsd.org/changeset/base/365071
>>> 
>>> Log:
>>> net: clean up empty lines in .c and .h files
>> 
>> Hi Mateusz,
>> 
>> which rules are enforced? Why?
> 
> This is common sense.  I can't count how often I wanted to hack on
> something in the base/kernel and was turned away by this atrocious
> excessive whitespace mess.
This answers why. What rules were violated?

Best regards
Michael
> 
> Thank you Mateusz for cleaning this up.
> 
> ./danfe



smime.p7s
Description: S/MIME cryptographic signature


Re: svn commit: r365071 - in head/sys: net net/altq net/route net80211 netgraph netgraph/atm netgraph/atm/ccatm netgraph/atm/sscfu netgraph/atm/sscop netgraph/atm/uni netgraph/bluetooth/common netgrap

2020-09-01 Thread Michael Tuexen
> On 1. Sep 2020, at 23:19, Mateusz Guzik  wrote:
> 
> Author: mjg
> Date: Tue Sep  1 21:19:14 2020
> New Revision: 365071
> URL: https://svnweb.freebsd.org/changeset/base/365071
> 
> Log:
>  net: clean up empty lines in .c and .h files
Hi Mateusz,

which rules are enforced? Why?

Best regards
Michael
> 
> Modified:
>  head/sys/net/altq/altq.h
>  head/sys/net/altq/altq_cbq.c
>  head/sys/net/altq/altq_cbq.h
>  head/sys/net/altq/altq_codel.c
>  head/sys/net/altq/altq_fairq.c
>  head/sys/net/altq/altq_hfsc.c
>  head/sys/net/altq/altq_hfsc.h
>  head/sys/net/altq/altq_priq.c
>  head/sys/net/altq/altq_priq.h
>  head/sys/net/altq/altq_red.c
>  head/sys/net/altq/altq_red.h
>  head/sys/net/altq/altq_rio.c
>  head/sys/net/altq/altq_rio.h
>  head/sys/net/altq/altq_rmclass.c
>  head/sys/net/altq/altq_subr.c
>  head/sys/net/altq/if_altq.h
>  head/sys/net/bpf.c
>  head/sys/net/bridgestp.c
>  head/sys/net/bridgestp.h
>  head/sys/net/debugnet_inet.c
>  head/sys/net/ieee8023ad_lacp.c
>  head/sys/net/if.c
>  head/sys/net/if.h
>  head/sys/net/if_bridge.c
>  head/sys/net/if_clone.c
>  head/sys/net/if_dl.h
>  head/sys/net/if_epair.c
>  head/sys/net/if_ethersubr.c
>  head/sys/net/if_gif.c
>  head/sys/net/if_ipsec.c
>  head/sys/net/if_lagg.c
>  head/sys/net/if_llatbl.c
>  head/sys/net/if_loop.c
>  head/sys/net/if_media.c
>  head/sys/net/if_media.h
>  head/sys/net/if_mib.c
>  head/sys/net/if_pfsync.h
>  head/sys/net/if_spppsubr.c
>  head/sys/net/if_tuntap.c
>  head/sys/net/if_vlan.c
>  head/sys/net/iflib.c
>  head/sys/net/iflib.h
>  head/sys/net/iflib_clone.c
>  head/sys/net/ifq.h
>  head/sys/net/mp_ring.c
>  head/sys/net/netisr.c
>  head/sys/net/netmap.h
>  head/sys/net/netmap_legacy.h
>  head/sys/net/netmap_user.h
>  head/sys/net/pfvar.h
>  head/sys/net/radix.c
>  head/sys/net/radix_mpath.c
>  head/sys/net/route.c
>  head/sys/net/route/nhop.c
>  head/sys/net/route/nhop.h
>  head/sys/net/route/nhop_ctl.c
>  head/sys/net/route/nhop_utils.c
>  head/sys/net/route/nhop_utils.h
>  head/sys/net/route/nhop_var.h
>  head/sys/net/route/route_ctl.c
>  head/sys/net/route/route_ctl.h
>  head/sys/net/route/route_helpers.c
>  head/sys/net/route/route_tables.c
>  head/sys/net/route/route_temporal.c
>  head/sys/net/route/route_var.h
>  head/sys/net/rss_config.c
>  head/sys/net/rtsock.c
>  head/sys/net/sff8436.h
>  head/sys/net/sff8472.h
>  head/sys/net/slcompress.c
>  head/sys/net/slcompress.h
>  head/sys/net/vnet.h
>  head/sys/net80211/ieee80211.h
>  head/sys/net80211/ieee80211_action.c
>  head/sys/net80211/ieee80211_ageq.c
>  head/sys/net80211/ieee80211_crypto.c
>  head/sys/net80211/ieee80211_crypto_tkip.c
>  head/sys/net80211/ieee80211_freebsd.c
>  head/sys/net80211/ieee80211_freebsd.h
>  head/sys/net80211/ieee80211_hostap.c
>  head/sys/net80211/ieee80211_ht.c
>  head/sys/net80211/ieee80211_hwmp.c
>  head/sys/net80211/ieee80211_input.c
>  head/sys/net80211/ieee80211_ioctl.c
>  head/sys/net80211/ieee80211_ioctl.h
>  head/sys/net80211/ieee80211_mesh.c
>  head/sys/net80211/ieee80211_mesh.h
>  head/sys/net80211/ieee80211_node.c
>  head/sys/net80211/ieee80211_output.c
>  head/sys/net80211/ieee80211_phy.c
>  head/sys/net80211/ieee80211_power.c
>  head/sys/net80211/ieee80211_proto.c
>  head/sys/net80211/ieee80211_radiotap.c
>  head/sys/net80211/ieee80211_radiotap.h
>  head/sys/net80211/ieee80211_scan.c
>  head/sys/net80211/ieee80211_scan_sta.c
>  head/sys/net80211/ieee80211_scan_sw.c
>  head/sys/net80211/ieee80211_sta.c
>  head/sys/net80211/ieee80211_superg.c
>  head/sys/net80211/ieee80211_tdma.h
>  head/sys/net80211/ieee80211_vht.c
>  head/sys/netgraph/atm/ccatm/ng_ccatm.c
>  head/sys/netgraph/atm/ng_sscop.h
>  head/sys/netgraph/atm/ngatmbase.c
>  head/sys/netgraph/atm/sscfu/ng_sscfu.c
>  head/sys/netgraph/atm/sscfu/ng_sscfu_cust.h
>  head/sys/netgraph/atm/sscop/ng_sscop.c
>  head/sys/netgraph/atm/sscop/ng_sscop_cust.h
>  head/sys/netgraph/atm/uni/ng_uni.c
>  head/sys/netgraph/bluetooth/common/ng_bluetooth.c
>  head/sys/netgraph/bluetooth/drivers/bt3c/ng_bt3c_pccard.c
>  head/sys/netgraph/bluetooth/drivers/bt3c/ng_bt3c_var.h
>  head/sys/netgraph/bluetooth/drivers/h4/ng_h4.c
>  head/sys/netgraph/bluetooth/drivers/h4/ng_h4_prse.h
>  head/sys/netgraph/bluetooth/drivers/h4/ng_h4_var.h
>  head/sys/netgraph/bluetooth/drivers/ubt/ng_ubt.c
>  head/sys/netgraph/bluetooth/drivers/ubt/ng_ubt_var.h
>  head/sys/netgraph/bluetooth/drivers/ubtbcmfw/ubtbcmfw.c
>  head/sys/netgraph/bluetooth/hci/ng_hci_cmds.c
>  head/sys/netgraph/bluetooth/hci/ng_hci_cmds.h
>  head/sys/netgraph/bluetooth/hci/ng_hci_evnt.c
>  head/sys/netgraph/bluetooth/hci/ng_hci_evnt.h
>  head/sys/netgraph/bluetooth/hci/ng_hci_main.c
>  head/sys/netgraph/bluetooth/hci/ng_hci_misc.c
>  head/sys/netgraph/bluetooth/hci/ng_hci_misc.h
>  head/sys/netgraph/bluetooth/hci/ng_hci_prse.h
>  head/sys/netgraph/bluetooth/hci/ng_hci_ulpi.c
>  head/sys/netgraph/bluetooth/hci/ng_hci_ulpi.h
>  head/sys/netgraph/bluetooth/hci/ng_hci_var.h
>  head/sys/netgraph/bluetooth/include/ng_bluetooth.h
>  

svn commit: r364937 - head/sys/netinet

2020-08-28 Thread Michael Tuexen
Author: tuexen
Date: Fri Aug 28 20:05:18 2020
New Revision: 364937
URL: https://svnweb.freebsd.org/changeset/base/364937

Log:
  Fix a regression with the explicit EOR mode I introduced in r364268.
  A short MFC time as discussed with the secteam.
  
  Reported by:  Taylor Brandstetter
  MFC after:1 day

Modified:
  head/sys/netinet/sctp_output.c

Modified: head/sys/netinet/sctp_output.c
==
--- head/sys/netinet/sctp_output.c  Fri Aug 28 20:03:54 2020
(r364936)
+++ head/sys/netinet/sctp_output.c  Fri Aug 28 20:05:18 2020
(r364937)
@@ -13118,11 +13118,10 @@ skip_preblock:
error = EINVAL;
goto out;
}
-   SCTP_TCB_SEND_UNLOCK(stcb);
-
strm = >asoc.strmout[srcv->sinfo_stream];
if (strm->last_msg_incomplete == 0) {
do_a_copy_in:
+   SCTP_TCB_SEND_UNLOCK(stcb);
sp = sctp_copy_it_in(stcb, asoc, srcv, uio, net, 
max_len, user_marks_eor, );
if (error) {
goto out;
@@ -13151,19 +13150,8 @@ skip_preblock:
sp->processing = 1;
TAILQ_INSERT_TAIL(>outqueue, sp, next);
stcb->asoc.ss_functions.sctp_ss_add_to_stream(stcb, 
asoc, strm, sp, 1);
-   SCTP_TCB_SEND_UNLOCK(stcb);
} else {
-   SCTP_TCB_SEND_LOCK(stcb);
sp = TAILQ_LAST(>outqueue, sctp_streamhead);
-   if (sp->processing) {
-   SCTP_TCB_SEND_UNLOCK(stcb);
-   SCTP_LTRACE_ERR_RET(inp, stcb, net, 
SCTP_FROM_SCTP_OUTPUT, EINVAL);
-   error = EINVAL;
-   goto out;
-   } else {
-   sp->processing = 1;
-   }
-   SCTP_TCB_SEND_UNLOCK(stcb);
if (sp == NULL) {
/*  Huh ??? last msg is gone */
 #ifdef INVARIANTS
@@ -13175,7 +13163,16 @@ skip_preblock:
goto do_a_copy_in;
 
}
+   if (sp->processing) {
+   SCTP_TCB_SEND_UNLOCK(stcb);
+   SCTP_LTRACE_ERR_RET(inp, stcb, net, 
SCTP_FROM_SCTP_OUTPUT, EINVAL);
+   error = EINVAL;
+   goto out;
+   } else {
+   sp->processing = 1;
+   }
}
+   SCTP_TCB_SEND_UNLOCK(stcb);
while (uio->uio_resid > 0) {
/* How much room do we have? */
struct mbuf *new_tail, *mm;
@@ -13200,6 +13197,11 @@ skip_preblock:
if (mm) {
sctp_m_freem(mm);
}
+   SCTP_TCB_SEND_LOCK(stcb);
+   if (sp != NULL) {
+   sp->processing = 0;
+   }
+   SCTP_TCB_SEND_UNLOCK(stcb);
goto out;
}
/* Update the mbuf and count */
@@ -13215,6 +13217,9 @@ skip_preblock:
SCTP_LTRACE_ERR_RET(NULL, stcb, 
NULL, SCTP_FROM_SCTP_OUTPUT, ECONNRESET);
error = ECONNRESET;
}
+   if (sp != NULL) {
+   sp->processing = 0;
+   }
SCTP_TCB_SEND_UNLOCK(stcb);
goto out;
}
@@ -13274,6 +13279,11 @@ skip_preblock:
/* wait for space now */
if (non_blocking) {
/* Non-blocking io in place out */
+   SCTP_TCB_SEND_LOCK(stcb);
+   if (sp != NULL) {
+   sp->processing = 0;
+   }
+   SCTP_TCB_SEND_UNLOCK(stcb);
goto skip_out_eof;
}
/* What about the INIT, send it maybe */
@@ -13401,6 +13411,11 @@ skip_preblock:
}
}

svn commit: r364754 - in head/sys/netinet: . tcp_stacks

2020-08-25 Thread Michael Tuexen
Author: tuexen
Date: Tue Aug 25 09:42:03 2020
New Revision: 364754
URL: https://svnweb.freebsd.org/changeset/base/364754

Log:
  RFC 3465 defines a limit L used in TCP slow start for limiting the number
  of acked bytes as described in Section 2.2 of that document.
  This patch ensures that this limit is not also applied in congestion
  avoidance. Applying this limit also in congestion avoidance can result in
  using less bandwidth than allowed.
  
  Reported by:  l.tian.em...@gmail.com
  Reviewed by:  rrs, rscheff
  MFC after:3 days
  Sponsored by: Netflix, Inc.
  Differential Revision:https://reviews.freebsd.org/D26120

Modified:
  head/sys/netinet/tcp_input.c
  head/sys/netinet/tcp_stacks/rack.c

Modified: head/sys/netinet/tcp_input.c
==
--- head/sys/netinet/tcp_input.cTue Aug 25 06:49:10 2020
(r364753)
+++ head/sys/netinet/tcp_input.cTue Aug 25 09:42:03 2020
(r364754)
@@ -349,8 +349,7 @@ cc_ack_received(struct tcpcb *tp, struct tcphdr *th, u
}
 #endif /* STATS */
if (tp->snd_cwnd > tp->snd_ssthresh) {
-   tp->t_bytes_acked += min(tp->ccv->bytes_this_ack,
-nsegs * V_tcp_abc_l_var * tcp_maxseg(tp));
+   tp->t_bytes_acked += tp->ccv->bytes_this_ack;
if (tp->t_bytes_acked >= tp->snd_cwnd) {
tp->t_bytes_acked -= tp->snd_cwnd;
tp->ccv->flags |= CCF_ABC_SENTAWND;

Modified: head/sys/netinet/tcp_stacks/rack.c
==
--- head/sys/netinet/tcp_stacks/rack.c  Tue Aug 25 06:49:10 2020
(r364753)
+++ head/sys/netinet/tcp_stacks/rack.c  Tue Aug 25 09:42:03 2020
(r364754)
@@ -3911,8 +3911,7 @@ rack_ack_received(struct tcpcb *tp, struct tcp_rack *r
 #endif
}
if (rack->r_ctl.cwnd_to_use > tp->snd_ssthresh) {
-   tp->t_bytes_acked += min(tp->ccv->bytes_this_ack,
-nsegs * V_tcp_abc_l_var * ctf_fixed_maxseg(tp));
+   tp->t_bytes_acked += tp->ccv->bytes_this_ack;
if (tp->t_bytes_acked >= rack->r_ctl.cwnd_to_use) {
tp->t_bytes_acked -= rack->r_ctl.cwnd_to_use;
tp->ccv->flags |= CCF_ABC_SENTAWND;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r364353 - head/sys/netinet

2020-08-18 Thread Michael Tuexen
Author: tuexen
Date: Tue Aug 18 19:25:03 2020
New Revision: 364353
URL: https://svnweb.freebsd.org/changeset/base/364353

Log:
  Fix two bugs I introduced in r362563.
  Found by running syzkaller.
  
  MFC after:3 days

Modified:
  head/sys/netinet/sctp_usrreq.c

Modified: head/sys/netinet/sctp_usrreq.c
==
--- head/sys/netinet/sctp_usrreq.c  Tue Aug 18 17:30:51 2020
(r364352)
+++ head/sys/netinet/sctp_usrreq.c  Tue Aug 18 19:25:03 2020
(r364353)
@@ -1124,7 +1124,7 @@ sctp_fill_up_addresses_vrf(struct sctp_inpcb *inp,
if (actual + 
sizeof(struct sockaddr_in6) > limit) {
return (actual);
}
-   
in6_sin_2_v4mapsin6(sin, (struct sockaddr_in6 *));
+   
in6_sin_2_v4mapsin6(sin, (struct sockaddr_in6 *)addr);
((struct sockaddr_in6 
*)addr)->sin6_port = inp->sctp_lport;
addr = (struct sockaddr 
*)((caddr_t)addr + sizeof(struct sockaddr_in6));
actual += sizeof(struct 
sockaddr_in6);
@@ -2271,7 +2271,7 @@ flags_out:
(net->ro._l_addr.sa.sa_family == 
AF_INET)) {
/* Must map the address */

in6_sin_2_v4mapsin6(>ro._l_addr.sin,
-   (struct sockaddr_in6 
*));
+   (struct sockaddr_in6 
*)addr);
} else {
memcpy(addr, >ro._l_addr, 
cpsz);
}
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r364270 - head/sys/netinet

2020-08-16 Thread Michael Tuexen
Author: tuexen
Date: Sun Aug 16 13:31:14 2020
New Revision: 364270
URL: https://svnweb.freebsd.org/changeset/base/364270

Log:
  Remove a line which is needed and was added in
  https://svnweb.freebsd.org/changeset/base/364268
  
  MFC after:3 days

Modified:
  head/sys/netinet/sctp_usrreq.c

Modified: head/sys/netinet/sctp_usrreq.c
==
--- head/sys/netinet/sctp_usrreq.c  Sun Aug 16 12:59:43 2020
(r364269)
+++ head/sys/netinet/sctp_usrreq.c  Sun Aug 16 13:31:14 2020
(r364270)
@@ -190,7 +190,6 @@ sctp_notify(struct sctp_inpcb *inp,
} else if ((icmp_code == ICMP_UNREACH_PROTOCOL) ||
(icmp_code == ICMP_UNREACH_PORT)) {
/* Treat it like an ABORT. */
-   SCTP_ADD_SUBSTATE(stcb, SCTP_STATE_WAS_ABORTED);
sctp_abort_notification(stcb, 1, 0, NULL, SCTP_SO_NOT_LOCKED);
(void)sctp_free_assoc(inp, stcb, SCTP_NORMAL_PROC,
SCTP_FROM_SCTP_USRREQ + SCTP_LOC_2);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r364268 - head/sys/netinet

2020-08-16 Thread Michael Tuexen
Author: tuexen
Date: Sun Aug 16 11:50:37 2020
New Revision: 364268
URL: https://svnweb.freebsd.org/changeset/base/364268

Log:
  Improve the handling of concurrent send() calls for SCTP sockets,
  especially when having the explicit EOR mode enabled.
  
  Reported by:  megan2013...@protonmail.com
  Reported by:  syzbot+bc02585076c3cc977...@syzkaller.appspotmail.com
  MFC after:3 days

Modified:
  head/sys/netinet/sctp_input.c
  head/sys/netinet/sctp_output.c
  head/sys/netinet/sctp_pcb.c
  head/sys/netinet/sctp_structs.h
  head/sys/netinet/sctp_usrreq.c
  head/sys/netinet/sctputil.c
  head/sys/netinet/sctputil.h

Modified: head/sys/netinet/sctp_input.c
==
--- head/sys/netinet/sctp_input.c   Sun Aug 16 11:37:28 2020
(r364267)
+++ head/sys/netinet/sctp_input.c   Sun Aug 16 11:50:37 2020
(r364268)
@@ -829,7 +829,6 @@ sctp_handle_abort(struct sctp_abort_chunk *abort,
 #ifdef SCTP_ASOCLOG_OF_TSNS
sctp_print_out_track_log(stcb);
 #endif
-   SCTP_ADD_SUBSTATE(stcb, SCTP_STATE_WAS_ABORTED);
(void)sctp_free_assoc(stcb->sctp_ep, stcb, SCTP_NORMAL_PROC,
SCTP_FROM_SCTP_INPUT + SCTP_LOC_8);
SCTPDBG(SCTP_DEBUG_INPUT2, "sctp_handle_abort: finished\n");
@@ -1866,7 +1865,7 @@ sctp_process_cookie_existing(struct mbuf *m, int iphle
/* send up all the data */
SCTP_TCB_SEND_LOCK(stcb);
 
-   sctp_report_all_outbound(stcb, 0, 1, SCTP_SO_LOCKED);
+   sctp_report_all_outbound(stcb, 0, SCTP_SO_LOCKED);
for (i = 0; i < stcb->asoc.streamoutcnt; i++) {
stcb->asoc.strmout[i].chunks_on_queues = 0;
 #if defined(SCTP_DETAILED_STR_STATS)

Modified: head/sys/netinet/sctp_output.c
==
--- head/sys/netinet/sctp_output.c  Sun Aug 16 11:37:28 2020
(r364267)
+++ head/sys/netinet/sctp_output.c  Sun Aug 16 11:50:37 2020
(r364268)
@@ -13148,12 +13148,21 @@ skip_preblock:
if (sinfo_flags & SCTP_UNORDERED) {
SCTP_STAT_INCR(sctps_sends_with_unord);
}
+   sp->processing = 1;
TAILQ_INSERT_TAIL(>outqueue, sp, next);
stcb->asoc.ss_functions.sctp_ss_add_to_stream(stcb, 
asoc, strm, sp, 1);
SCTP_TCB_SEND_UNLOCK(stcb);
} else {
SCTP_TCB_SEND_LOCK(stcb);
sp = TAILQ_LAST(>outqueue, sctp_streamhead);
+   if (sp->processing) {
+   SCTP_TCB_SEND_UNLOCK(stcb);
+   SCTP_LTRACE_ERR_RET(inp, stcb, net, 
SCTP_FROM_SCTP_OUTPUT, EINVAL);
+   error = EINVAL;
+   goto out;
+   } else {
+   sp->processing = 1;
+   }
SCTP_TCB_SEND_UNLOCK(stcb);
if (sp == NULL) {
/*  Huh ??? last msg is gone */
@@ -13195,13 +13204,14 @@ skip_preblock:
}
/* Update the mbuf and count */
SCTP_TCB_SEND_LOCK(stcb);
-   if (stcb->asoc.state & 
SCTP_STATE_ABOUT_TO_BE_FREED) {
+   if ((stcb->asoc.state & 
SCTP_STATE_ABOUT_TO_BE_FREED) ||
+   (stcb->asoc.state & 
SCTP_STATE_WAS_ABORTED)) {
/*
 * we need to get out. Peer probably
 * aborted.
 */
sctp_m_freem(mm);
-   if (stcb->asoc.state & 
SCTP_PCB_FLAGS_WAS_ABORTED) {
+   if (stcb->asoc.state & 
SCTP_STATE_WAS_ABORTED) {
SCTP_LTRACE_ERR_RET(NULL, stcb, 
NULL, SCTP_FROM_SCTP_OUTPUT, ECONNRESET);
error = ECONNRESET;
}
@@ -13405,7 +13415,8 @@ skip_preblock:
}
}
SCTP_TCB_SEND_LOCK(stcb);
-   if (stcb->asoc.state & SCTP_STATE_ABOUT_TO_BE_FREED) {
+   if ((stcb->asoc.state & SCTP_STATE_ABOUT_TO_BE_FREED) ||
+   (stcb->asoc.state & SCTP_STATE_WAS_ABORTED)) {
SCTP_TCB_SEND_UNLOCK(stcb);
goto out_unlocked;
}
@@ -13421,6 +13432,7 @@ skip_preblock:
strm->last_msg_incomplete = 0;

svn commit: r364247 - head/sys/netinet

2020-08-15 Thread Michael Tuexen
Author: tuexen
Date: Sat Aug 15 11:22:07 2020
New Revision: 364247
URL: https://svnweb.freebsd.org/changeset/base/364247

Log:
  Enter epoch earlier. This is needed because we are exiting it also
  in error cases.
  
  MFC after:1 week

Modified:
  head/sys/netinet/sctputil.c

Modified: head/sys/netinet/sctputil.c
==
--- head/sys/netinet/sctputil.c Sat Aug 15 07:22:48 2020(r364246)
+++ head/sys/netinet/sctputil.c Sat Aug 15 11:22:07 2020(r364247)
@@ -1727,6 +1727,7 @@ sctp_timeout_handler(void *t)
stcb = (struct sctp_tcb *)tmr->tcb;
net = (struct sctp_nets *)tmr->net;
CURVNET_SET((struct vnet *)tmr->vnet);
+   NET_EPOCH_ENTER(et);
did_output = 1;
released_asoc_reference = false;
 
@@ -1786,7 +1787,6 @@ sctp_timeout_handler(void *t)
 
/* Record in stopped_from which timeout occurred. */
tmr->stopped_from = type;
-   NET_EPOCH_ENTER(et);
/* mark as being serviced now */
if (SCTP_OS_TIMER_PENDING(>timer)) {
/*
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r364089 - head/sys/netinet

2020-08-10 Thread Michael Tuexen
Author: tuexen
Date: Mon Aug 10 20:24:48 2020
New Revision: 364089
URL: https://svnweb.freebsd.org/changeset/base/364089

Log:
  Fix the following issues related to the TCP SYN-cache:
  * Let the accepted TCP/IPv4 socket inherit the configured TTL and
TOS value.
  * Let the accepted TCP/IPv6 socket inherit the configured Hop Limit.
  * Use the configured Hop Limit and Traffic Class when sending
IPv6 packets.
  
  Reviewed by:  rrs, lutz_donnerhacke.de
  MFC after:1 week
  Sponsored by: Netflix, Inc.
  Differential Revision:https://reviews.freebsd.org/D25909

Modified:
  head/sys/netinet/tcp_syncache.c
  head/sys/netinet/tcp_syncache.h

Modified: head/sys/netinet/tcp_syncache.c
==
--- head/sys/netinet/tcp_syncache.c Mon Aug 10 19:37:06 2020
(r364088)
+++ head/sys/netinet/tcp_syncache.c Mon Aug 10 20:24:48 2020
(r364089)
@@ -831,6 +831,8 @@ syncache_socket(struct syncache *sc, struct socket *ls
inp->inp_vflag &= ~INP_IPV6;
inp->inp_vflag |= INP_IPV4;
 #endif
+   inp->inp_ip_ttl = sc->sc_ip_ttl;
+   inp->inp_ip_tos = sc->sc_ip_tos;
inp->inp_laddr = sc->sc_inc.inc_laddr;
 #ifdef INET6
}
@@ -866,6 +868,7 @@ syncache_socket(struct syncache *sc, struct socket *ls
if (oinp->in6p_outputopts)
inp->in6p_outputopts =
ip6_copypktopts(oinp->in6p_outputopts, M_NOWAIT);
+   inp->in6p_hops = oinp->in6p_hops;
}
 
if (sc->sc_inc.inc_flags & INC_ISIPV6) {
@@ -1389,12 +1392,28 @@ syncache_add(struct in_conninfo *inc, struct tcpopt *t
cred = crhold(so->so_cred);
 
 #ifdef INET6
-   if ((inc->inc_flags & INC_ISIPV6) &&
-   (inp->inp_flags & IN6P_AUTOFLOWLABEL))
-   autoflowlabel = 1;
+   if (inc->inc_flags & INC_ISIPV6) {
+   if (inp->inp_flags & IN6P_AUTOFLOWLABEL) {
+   autoflowlabel = 1;
+   }
+   ip_ttl = in6_selecthlim(inp, NULL);
+   if ((inp->in6p_outputopts == NULL) ||
+   (inp->in6p_outputopts->ip6po_tclass == -1)) {
+   ip_tos = 0;
+   } else {
+   ip_tos = inp->in6p_outputopts->ip6po_tclass;
+   }
+   }
 #endif
-   ip_ttl = inp->inp_ip_ttl;
-   ip_tos = inp->inp_ip_tos;
+#if defined(INET6) && defined(INET)
+   else
+#endif
+#ifdef INET
+   {
+   ip_ttl = inp->inp_ip_ttl;
+   ip_tos = inp->inp_ip_tos;
+   }
+#endif
win = so->sol_sbrcv_hiwat;
ltflags = (tp->t_flags & (TF_NOOPT | TF_SIGNATURE));
 
@@ -1599,13 +1618,8 @@ skip_alloc:
cred = NULL;
sc->sc_ipopts = ipopts;
bcopy(inc, >sc_inc, sizeof(struct in_conninfo));
-#ifdef INET6
-   if (!(inc->inc_flags & INC_ISIPV6))
-#endif
-   {
-   sc->sc_ip_tos = ip_tos;
-   sc->sc_ip_ttl = ip_ttl;
-   }
+   sc->sc_ip_tos = ip_tos;
+   sc->sc_ip_ttl = ip_ttl;
 #ifdef TCP_OFFLOAD
sc->sc_tod = tod;
sc->sc_todctx = todctx;
@@ -1807,6 +1821,7 @@ syncache_respond(struct syncache *sc, const struct mbu
/* Zero out traffic class and flow label. */
ip6->ip6_flow &= ~IPV6_FLOWINFO_MASK;
ip6->ip6_flow |= sc->sc_flowlabel;
+   ip6->ip6_flow |= htonl(sc->sc_ip_tos << 20);
 
th = (struct tcphdr *)(ip6 + 1);
}
@@ -1935,7 +1950,7 @@ syncache_respond(struct syncache *sc, const struct mbu
m->m_pkthdr.csum_flags = CSUM_TCP_IPV6;
th->th_sum = in6_cksum_pseudo(ip6, tlen + optlen - hlen,
IPPROTO_TCP, 0);
-   ip6->ip6_hlim = in6_selecthlim(NULL, NULL);
+   ip6->ip6_hlim = sc->sc_ip_ttl;
 #ifdef TCP_OFFLOAD
if (ADDED_BY_TOE(sc)) {
struct toedev *tod = sc->sc_tod;

Modified: head/sys/netinet/tcp_syncache.h
==
--- head/sys/netinet/tcp_syncache.h Mon Aug 10 19:37:06 2020
(r364088)
+++ head/sys/netinet/tcp_syncache.h Mon Aug 10 20:24:48 2020
(r364089)
@@ -63,8 +63,8 @@ struct syncache {
struct  mbuf *sc_ipopts;/* source route */
u_int16_t   sc_peer_mss;/* peer's MSS */
u_int16_t   sc_wnd; /* advertised window */
-   u_int8_tsc_ip_ttl;  /* IPv4 TTL */
-   u_int8_tsc_ip_tos;  /* IPv4 TOS */
+   u_int8_tsc_ip_ttl;  /* TTL / Hop Limit */
+   u_int8_tsc_ip_tos;  /* TOS / Traffic Class */
u_int8_tsc_requested_s_scale:4,
sc_requested_r_scale:4;
u_int16_t   

svn commit: r364054 - head/sys/netinet

2020-08-08 Thread Michael Tuexen
Author: tuexen
Date: Sat Aug  8 19:39:38 2020
New Revision: 364054
URL: https://svnweb.freebsd.org/changeset/base/364054

Log:
  Improve the ECN negotiation when the TCP SYN-cache is used by making
  sure that
  * ECN is disabled if the client sends an non-ECN-setup SYN segment.
  * ECN is disabled is the ECN-setup SYN-ACK segment is retransmitted more
than net.inet.tcp.ecn.maxretries times.
  
  Reviewed by:  rscheff
  MFC after:1 week
  Sponsored by: Netflix, Inc.
  Differential Revision:https://reviews.freebsd.org/D26008

Modified:
  head/sys/netinet/tcp_syncache.c

Modified: head/sys/netinet/tcp_syncache.c
==
--- head/sys/netinet/tcp_syncache.c Sat Aug  8 16:56:20 2020
(r364053)
+++ head/sys/netinet/tcp_syncache.c Sat Aug  8 19:39:38 2020
(r364054)
@@ -510,6 +510,9 @@ syncache_timer(void *xsch)
sch->sch_nextc = sc->sc_rxttime;
continue;
}
+   if (sc->sc_rxmits > V_tcp_ecn_maxretries) {
+   sc->sc_flags &= ~SCF_ECN;
+   }
if (sc->sc_rxmits > V_tcp_syncache.rexmt_limit) {
if ((s = tcp_log_addrs(>sc_inc, NULL, NULL, NULL))) 
{
log(LOG_DEBUG, "%s; %s: Retransmits exhausted, "
@@ -1505,6 +1508,13 @@ syncache_add(struct in_conninfo *inc, struct tcpopt *t
sc->sc_tsreflect = to->to_tsval;
else
sc->sc_flags &= ~SCF_TIMESTAMP;
+   /*
+* Disable ECN if needed.
+*/
+   if ((sc->sc_flags & SCF_ECN) &&
+   ((th->th_flags & (TH_ECE|TH_CWR)) != (TH_ECE|TH_CWR))) {
+   sc->sc_flags &= ~SCF_ECN;
+   }
 #ifdef MAC
/*
 * Since we have already unconditionally allocated label
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r363456 - head/sys/netinet

2020-07-23 Thread Michael Tuexen
Author: tuexen
Date: Thu Jul 23 19:43:49 2020
New Revision: 363456
URL: https://svnweb.freebsd.org/changeset/base/363456

Log:
  Clear the pointer to the socket when closing it also in case of
  an ungraceful operation.
  This fixes a use-after-free bug found and reported by Taylor
  Brandstetter of Google by testing the userland stack.
  
  MFC after:1 week

Modified:
  head/sys/netinet/sctp_pcb.c

Modified: head/sys/netinet/sctp_pcb.c
==
--- head/sys/netinet/sctp_pcb.c Thu Jul 23 19:19:33 2020(r363455)
+++ head/sys/netinet/sctp_pcb.c Thu Jul 23 19:43:49 2020(r363456)
@@ -3545,6 +3545,11 @@ sctp_inpcb_free(struct sctp_inpcb *inp, int immediate,
cnt = 0;
LIST_FOREACH_SAFE(asoc, >sctp_asoc_list, sctp_tcblist, nasoc) {
SCTP_TCB_LOCK(asoc);
+   if (immediate != SCTP_FREE_SHOULD_USE_GRACEFUL_CLOSE) {
+   /* Disconnect the socket please */
+   asoc->sctp_socket = NULL;
+   SCTP_ADD_SUBSTATE(asoc, SCTP_STATE_CLOSED_SOCKET);
+   }
if (asoc->asoc.state & SCTP_STATE_ABOUT_TO_BE_FREED) {
if (asoc->asoc.state & SCTP_STATE_IN_ACCEPT_QUEUE) {
SCTP_CLEAR_SUBSTATE(asoc, 
SCTP_STATE_IN_ACCEPT_QUEUE);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r363440 - head/sys/netinet

2020-07-22 Thread Michael Tuexen
Author: tuexen
Date: Thu Jul 23 01:35:24 2020
New Revision: 363440
URL: https://svnweb.freebsd.org/changeset/base/363440

Log:
  Detect and handle an invalid reassembly constellation, which results in
  a memory leak.
  
  Thanks to Felix Weinrank for finding this issue using fuzz testing the
  userland stack.
  
  MFC after:1 week

Modified:
  head/sys/netinet/sctp_constants.h
  head/sys/netinet/sctp_indata.c

Modified: head/sys/netinet/sctp_constants.h
==
--- head/sys/netinet/sctp_constants.h   Wed Jul 22 23:39:58 2020
(r363439)
+++ head/sys/netinet/sctp_constants.h   Thu Jul 23 01:35:24 2020
(r363440)
@@ -795,6 +795,7 @@ __FBSDID("$FreeBSD$");
 #define SCTP_LOC_34 0x0022
 #define SCTP_LOC_35 0x0023
 #define SCTP_LOC_36 0x0024
+#define SCTP_LOC_37 0x0025
 
 /* Free assoc codes */
 #define SCTP_NORMAL_PROC  0

Modified: head/sys/netinet/sctp_indata.c
==
--- head/sys/netinet/sctp_indata.c  Wed Jul 22 23:39:58 2020
(r363439)
+++ head/sys/netinet/sctp_indata.c  Thu Jul 23 01:35:24 2020
(r363440)
@@ -1567,6 +1567,15 @@ sctp_queue_data_for_reasm(struct sctp_tcb *stcb, struc
chk->rec.data.fsn);
TAILQ_FOREACH(at, >reasm, sctp_next) {
if (SCTP_TSN_GT(at->rec.data.fsn, chk->rec.data.fsn)) {
+   if (chk->rec.data.rcv_flags & 
SCTP_DATA_LAST_FRAG) {
+   /* Last not at the end? huh? */
+   SCTPDBG(SCTP_DEBUG_XXX,
+   "Last fragment not last in list: -- 
abort\n");
+   sctp_abort_in_reasm(stcb, control,
+   chk, abort_flag,
+   SCTP_FROM_SCTP_INDATA + 
SCTP_LOC_14);
+   return;
+   }
/*
 * This one in queue is bigger than the new
 * one, insert the new one before at.
@@ -1597,7 +1606,7 @@ sctp_queue_data_for_reasm(struct sctp_tcb *stcb, struc
at->rec.data.fsn);
sctp_abort_in_reasm(stcb, control,
chk, abort_flag,
-   SCTP_FROM_SCTP_INDATA + SCTP_LOC_14);
+   SCTP_FROM_SCTP_INDATA + SCTP_LOC_15);
return;
}
}
@@ -1751,7 +1760,7 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struc
 * Need to send an abort since we had a empty data chunk.
 */
op_err = sctp_generate_no_user_data_cause(tsn);
-   stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_INDATA + 
SCTP_LOC_15;
+   stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_INDATA + 
SCTP_LOC_16;
sctp_abort_an_association(stcb->sctp_ep, stcb, op_err, 
SCTP_SO_NOT_LOCKED);
*abort_flag = 1;
return (0);
@@ -1888,7 +1897,7 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struc
SCTP_SNPRINTF(msg, sizeof(msg), "Reassembly 
problem (MID=%8.8x)", mid);
err_out:
op_err = 
sctp_generate_cause(SCTP_CAUSE_PROTOCOL_VIOLATION, msg);
-   stcb->sctp_ep->last_abort_code = 
SCTP_FROM_SCTP_INDATA + SCTP_LOC_16;
+   stcb->sctp_ep->last_abort_code = 
SCTP_FROM_SCTP_INDATA + SCTP_LOC_17;
sctp_abort_an_association(stcb->sctp_ep, stcb, 
op_err, SCTP_SO_NOT_LOCKED);
*abort_flag = 1;
return (0);
@@ -2023,7 +2032,7 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struc
(uint16_t)mid);
}
op_err = sctp_generate_cause(SCTP_CAUSE_PROTOCOL_VIOLATION, 
msg);
-   stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_INDATA + 
SCTP_LOC_17;
+   stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_INDATA + 
SCTP_LOC_18;
sctp_abort_an_association(stcb->sctp_ep, stcb, op_err, 
SCTP_SO_NOT_LOCKED);
*abort_flag = 1;
return (0);
@@ -2597,7 +2606,7 @@ sctp_sack_check(struct sctp_tcb *stcb, int was_a_gap)
if (SCTP_OS_TIMER_PENDING(>asoc.dack_timer.timer)) {
sctp_timer_stop(SCTP_TIMER_TYPE_RECV,
stcb->sctp_ep, stcb, NULL,
-   SCTP_FROM_SCTP_INDATA + SCTP_LOC_18);
+   SCTP_FROM_SCTP_INDATA + SCTP_LOC_19);

svn commit: r363323 - head/sys/netinet

2020-07-19 Thread Michael Tuexen
Author: tuexen
Date: Sun Jul 19 12:34:19 2020
New Revision: 363323
URL: https://svnweb.freebsd.org/changeset/base/363323

Log:
  Add reference counts for inp/stcb/net when timers are running.
  This avoids a use-after-free reported for the userland stack.
  Thanks to Taylor Brandstetter for suggesting a patch for
  the userland stack.
  
  MFC after:1 week

Modified:
  head/sys/netinet/sctp_os_bsd.h
  head/sys/netinet/sctp_pcb.c
  head/sys/netinet/sctp_var.h
  head/sys/netinet/sctputil.c
  head/sys/netinet/sctputil.h

Modified: head/sys/netinet/sctp_os_bsd.h
==
--- head/sys/netinet/sctp_os_bsd.h  Sun Jul 19 12:25:03 2020
(r363322)
+++ head/sys/netinet/sctp_os_bsd.h  Sun Jul 19 12:34:19 2020
(r363323)
@@ -269,12 +269,17 @@ typedef struct callout sctp_os_timer_t;
 
 
 #define SCTP_OS_TIMER_INIT(tmr)callout_init(tmr, 1)
-#define SCTP_OS_TIMER_STARTcallout_reset
-#define SCTP_OS_TIMER_STOP callout_stop
-#define SCTP_OS_TIMER_STOP_DRAIN callout_drain
-#define SCTP_OS_TIMER_PENDING  callout_pending
-#define SCTP_OS_TIMER_ACTIVE   callout_active
-#define SCTP_OS_TIMER_DEACTIVATE callout_deactivate
+/*
+ * NOTE: The next two shouldn't be called directly outside of 
sctp_timer_start()
+ * and sctp_timer_stop(), since they don't handle incrementing/decrementing
+ * relevant reference counts.
+ */
+#define SCTP_OS_TIMER_STARTcallout_reset
+#define SCTP_OS_TIMER_STOP callout_stop
+#define SCTP_OS_TIMER_STOP_DRAIN   callout_drain
+#define SCTP_OS_TIMER_PENDING  callout_pending
+#define SCTP_OS_TIMER_ACTIVE   callout_active
+#define SCTP_OS_TIMER_DEACTIVATE   callout_deactivate
 
 #define sctp_get_tick_count() (ticks)
 

Modified: head/sys/netinet/sctp_pcb.c
==
--- head/sys/netinet/sctp_pcb.c Sun Jul 19 12:25:03 2020(r363322)
+++ head/sys/netinet/sctp_pcb.c Sun Jul 19 12:34:19 2020(r363323)
@@ -2739,23 +2739,54 @@ sctp_move_pcb_and_assoc(struct sctp_inpcb *old_inp, st
}
}
}
-   /*
-* Now any running timers need to be adjusted since we really don't
-* care if they are running or not just blast in the new_inp into
-* all of them.
-*/
-
-   stcb->asoc.dack_timer.ep = (void *)new_inp;
-   stcb->asoc.asconf_timer.ep = (void *)new_inp;
-   stcb->asoc.strreset_timer.ep = (void *)new_inp;
-   stcb->asoc.shut_guard_timer.ep = (void *)new_inp;
-   stcb->asoc.autoclose_timer.ep = (void *)new_inp;
-   stcb->asoc.delete_prim_timer.ep = (void *)new_inp;
+   /* Now any running timers need to be adjusted. */
+   if (stcb->asoc.dack_timer.ep == old_inp) {
+   SCTP_INP_DECR_REF(old_inp);
+   stcb->asoc.dack_timer.ep = new_inp;
+   SCTP_INP_INCR_REF(new_inp);
+   }
+   if (stcb->asoc.asconf_timer.ep == old_inp) {
+   SCTP_INP_DECR_REF(old_inp);
+   stcb->asoc.asconf_timer.ep = new_inp;
+   SCTP_INP_INCR_REF(new_inp);
+   }
+   if (stcb->asoc.strreset_timer.ep == old_inp) {
+   SCTP_INP_DECR_REF(old_inp);
+   stcb->asoc.strreset_timer.ep = new_inp;
+   SCTP_INP_INCR_REF(new_inp);
+   }
+   if (stcb->asoc.shut_guard_timer.ep == old_inp) {
+   SCTP_INP_DECR_REF(old_inp);
+   stcb->asoc.shut_guard_timer.ep = new_inp;
+   SCTP_INP_INCR_REF(new_inp);
+   }
+   if (stcb->asoc.autoclose_timer.ep == old_inp) {
+   SCTP_INP_DECR_REF(old_inp);
+   stcb->asoc.autoclose_timer.ep = new_inp;
+   SCTP_INP_INCR_REF(new_inp);
+   }
+   if (stcb->asoc.delete_prim_timer.ep == old_inp) {
+   SCTP_INP_DECR_REF(old_inp);
+   stcb->asoc.delete_prim_timer.ep = new_inp;
+   SCTP_INP_INCR_REF(new_inp);
+   }
/* now what about the nets? */
TAILQ_FOREACH(net, >asoc.nets, sctp_next) {
-   net->pmtu_timer.ep = (void *)new_inp;
-   net->hb_timer.ep = (void *)new_inp;
-   net->rxt_timer.ep = (void *)new_inp;
+   if (net->pmtu_timer.ep == old_inp) {
+   SCTP_INP_DECR_REF(old_inp);
+   net->pmtu_timer.ep = new_inp;
+   SCTP_INP_INCR_REF(new_inp);
+   }
+   if (net->hb_timer.ep == old_inp) {
+   SCTP_INP_DECR_REF(old_inp);
+   net->hb_timer.ep = new_inp;
+   SCTP_INP_INCR_REF(new_inp);
+   }
+   if (net->rxt_timer.ep == old_inp) {
+   SCTP_INP_DECR_REF(old_inp);
+   net->rxt_timer.ep = new_inp;
+   SCTP_INP_INCR_REF(new_inp);
+   }
}
  

svn commit: r363309 - head/sys/netinet

2020-07-18 Thread Michael Tuexen
Author: tuexen
Date: Sat Jul 18 13:10:02 2020
New Revision: 363309
URL: https://svnweb.freebsd.org/changeset/base/363309

Log:
  Remove code which is not needed.
  
  MFC after:1 week

Modified:
  head/sys/netinet/sctp_pcb.c

Modified: head/sys/netinet/sctp_pcb.c
==
--- head/sys/netinet/sctp_pcb.c Sat Jul 18 12:43:11 2020(r363308)
+++ head/sys/netinet/sctp_pcb.c Sat Jul 18 13:10:02 2020(r363309)
@@ -3593,9 +3593,6 @@ sctp_inpcb_free(struct sctp_inpcb *inp, int immediate,
 */
if (from != SCTP_CALLED_FROM_INPKILL_TIMER) {

(void)SCTP_OS_TIMER_STOP_DRAIN(>sctp_ep.signature_change.timer);
-   } else {
-   /* Probably un-needed */
-   (void)SCTP_OS_TIMER_STOP(>sctp_ep.signature_change.timer);
}
 
 #ifdef SCTP_LOG_CLOSING
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r363275 - head/sys/netinet

2020-07-17 Thread Michael Tuexen
Author: tuexen
Date: Fri Jul 17 15:09:49 2020
New Revision: 363275
URL: https://svnweb.freebsd.org/changeset/base/363275

Log:
  Improve the locking of address lists by adding some asserts and
  rearranging the addition of address such that the lock is not
  given up during checking and adding.
  
  MFC after:1 week

Modified:
  head/sys/netinet/sctp_lock_bsd.h
  head/sys/netinet/sctp_pcb.c
  head/sys/netinet/sctp_usrreq.c
  head/sys/netinet/sctputil.c

Modified: head/sys/netinet/sctp_lock_bsd.h
==
--- head/sys/netinet/sctp_lock_bsd.hFri Jul 17 14:51:51 2020
(r363274)
+++ head/sys/netinet/sctp_lock_bsd.hFri Jul 17 15:09:49 2020
(r363275)
@@ -177,6 +177,13 @@ __FBSDID("$FreeBSD$");
rw_wunlock(_BASE_INFO(ipi_addr_mtx));  \
 } while (0)
 
+#define SCTP_IPI_ADDR_LOCK_ASSERT() do {   \
+   rw_assert(_BASE_INFO(ipi_addr_mtx), RA_LOCKED);\
+} while (0)
+
+#define SCTP_IPI_ADDR_WLOCK_ASSERT() do {  \
+   rw_assert(_BASE_INFO(ipi_addr_mtx), RA_WLOCKED);   \
+} while (0)
 
 #define SCTP_IPI_ITERATOR_WQ_INIT() do {   \
mtx_init(_it_ctl.ipi_iterator_wq_mtx, "sctp-it-wq",\

Modified: head/sys/netinet/sctp_pcb.c
==
--- head/sys/netinet/sctp_pcb.c Fri Jul 17 14:51:51 2020(r363274)
+++ head/sys/netinet/sctp_pcb.c Fri Jul 17 15:09:49 2020(r363275)
@@ -200,6 +200,7 @@ sctp_find_ifn(void *ifn, uint32_t ifn_index)
 * We assume the lock is held for the addresses if that's wrong
 * problems could occur :-)
 */
+   SCTP_IPI_ADDR_LOCK_ASSERT();
hash_ifn_head = _BASE_INFO(vrf_ifn_hash)[(ifn_index & 
SCTP_BASE_INFO(vrf_ifn_hashmark))];
LIST_FOREACH(sctp_ifnp, hash_ifn_head, next_bucket) {
if (sctp_ifnp->ifn_index == ifn_index) {
@@ -295,12 +296,16 @@ sctp_delete_ifn(struct sctp_ifn *sctp_ifnp, int hold_a
/* Not in the list.. sorry */
return;
}
-   if (hold_addr_lock == 0)
+   if (hold_addr_lock == 0) {
SCTP_IPI_ADDR_WLOCK();
+   } else {
+   SCTP_IPI_ADDR_WLOCK_ASSERT();
+   }
LIST_REMOVE(sctp_ifnp, next_bucket);
LIST_REMOVE(sctp_ifnp, next_ifn);
-   if (hold_addr_lock == 0)
+   if (hold_addr_lock == 0) {
SCTP_IPI_ADDR_WUNLOCK();
+   }
/* Take away the reference, and possibly free it */
sctp_free_ifn(sctp_ifnp);
 }
@@ -486,8 +491,8 @@ sctp_add_addr_to_vrf(uint32_t vrf_id, void *ifn, uint3
 int dynamic_add)
 {
struct sctp_vrf *vrf;
-   struct sctp_ifn *sctp_ifnp = NULL;
-   struct sctp_ifa *sctp_ifap = NULL;
+   struct sctp_ifn *sctp_ifnp, *new_sctp_ifnp;
+   struct sctp_ifa *sctp_ifap, *new_sctp_ifap;
struct sctp_ifalist *hash_addr_head;
struct sctp_ifnlist *hash_ifn_head;
uint32_t hash_of_addr;
@@ -497,6 +502,23 @@ sctp_add_addr_to_vrf(uint32_t vrf_id, void *ifn, uint3
SCTPDBG(SCTP_DEBUG_PCB4, "vrf_id 0x%x: adding address: ", vrf_id);
SCTPDBG_ADDR(SCTP_DEBUG_PCB4, addr);
 #endif
+   SCTP_MALLOC(new_sctp_ifnp, struct sctp_ifn *,
+   sizeof(struct sctp_ifn), SCTP_M_IFN);
+   if (new_sctp_ifnp == NULL) {
+#ifdef INVARIANTS
+   panic("No memory for IFN");
+#endif
+   return (NULL);
+   }
+   SCTP_MALLOC(new_sctp_ifap, struct sctp_ifa *, sizeof(struct sctp_ifa), 
SCTP_M_IFA);
+   if (new_sctp_ifap == NULL) {
+#ifdef INVARIANTS
+   panic("No memory for IFA");
+#endif
+   SCTP_FREE(new_sctp_ifnp, SCTP_M_IFN);
+   return (NULL);
+   }
+
SCTP_IPI_ADDR_WLOCK();
sctp_ifnp = sctp_find_ifn(ifn, ifn_index);
if (sctp_ifnp) {
@@ -507,6 +529,8 @@ sctp_add_addr_to_vrf(uint32_t vrf_id, void *ifn, uint3
vrf = sctp_allocate_vrf(vrf_id);
if (vrf == NULL) {
SCTP_IPI_ADDR_WUNLOCK();
+   SCTP_FREE(new_sctp_ifnp, SCTP_M_IFN);
+   SCTP_FREE(new_sctp_ifap, SCTP_M_IFA);
return (NULL);
}
}
@@ -516,15 +540,8 @@ sctp_add_addr_to_vrf(uint32_t vrf_id, void *ifn, uint3
 * build one and add it, can't hold lock until after malloc
 * done though.
 */
-   SCTP_IPI_ADDR_WUNLOCK();
-   SCTP_MALLOC(sctp_ifnp, struct sctp_ifn *,
-   sizeof(struct sctp_ifn), SCTP_M_IFN);
-   if (sctp_ifnp == NULL) {
-#ifdef INVARIANTS
-   panic("No memory for IFN");
-#endif
-   return (NULL);
-   }
+

svn commit: r363256 - head/sys/netinet

2020-07-16 Thread Michael Tuexen
Author: tuexen
Date: Thu Jul 16 16:46:24 2020
New Revision: 363256
URL: https://svnweb.freebsd.org/changeset/base/363256

Log:
  (Re)-allow 0.0.0.0 to be used as an address in connect() for TCP
  In r361752 an error handling was introduced for using 0.0.0.0 or
  255.255.255.255 as the address in connect() for TCP, since both
  addresses can't be used. However, the stack maps 0.0.0.0 implicitly
  to a local address and at least two regressions were reported.
  Therefore, re-allow the usage of 0.0.0.0.
  While there, change the error indicated when using 255.255.255.255
  from EAFNOSUPPORT to EACCES as mentioned in the man-page of connect().
  
  Reviewed by:  rrs
  MFC after:1 week
  Sponsored by: Netflix, Inc.
  Differential Revision:https://reviews.freebsd.org/D25401

Modified:
  head/sys/netinet/tcp_usrreq.c

Modified: head/sys/netinet/tcp_usrreq.c
==
--- head/sys/netinet/tcp_usrreq.c   Thu Jul 16 16:32:16 2020
(r363255)
+++ head/sys/netinet/tcp_usrreq.c   Thu Jul 16 16:46:24 2020
(r363256)
@@ -553,9 +553,8 @@ tcp_usr_connect(struct socket *so, struct sockaddr *na
&& IN_MULTICAST(ntohl(sinp->sin_addr.s_addr)))
return (EAFNOSUPPORT);
if ((sinp->sin_family == AF_INET) &&
-   ((ntohl(sinp->sin_addr.s_addr) == INADDR_BROADCAST) ||
-(sinp->sin_addr.s_addr == INADDR_ANY)))
-   return(EAFNOSUPPORT);
+   (ntohl(sinp->sin_addr.s_addr) == INADDR_BROADCAST))
+   return (EACCES);
if ((error = prison_remote_ip4(td->td_ucred, >sin_addr)) != 0)
return (error);
 
@@ -656,9 +655,8 @@ tcp6_usr_connect(struct socket *so, struct sockaddr *n
error = EAFNOSUPPORT;
goto out;
}
-   if ((ntohl(sin.sin_addr.s_addr) == INADDR_BROADCAST) ||
-   (sin.sin_addr.s_addr == INADDR_ANY)) {
-   error = EAFNOSUPPORT;
+   if (ntohl(sin.sin_addr.s_addr) == INADDR_BROADCAST) {
+   error = EACCES;
goto out;
}
if ((error = prison_remote_ip4(td->td_ucred,
@@ -1033,11 +1031,10 @@ tcp_usr_send(struct socket *so, int flags, struct mbuf
error = EAFNOSUPPORT;
goto out;
}
-   if ((ntohl(sinp->sin_addr.s_addr) == INADDR_BROADCAST) 
||
-   (sinp->sin_addr.s_addr == INADDR_ANY)) {
+   if (ntohl(sinp->sin_addr.s_addr) == INADDR_BROADCAST) {
if (m)
m_freem(m);
-   error = EAFNOSUPPORT;
+   error = EACCES;
goto out;
}
if ((error = prison_remote_ip4(td->td_ucred,
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r363194 - head/sys/netinet

2020-07-14 Thread Michael Tuexen
Author: tuexen
Date: Tue Jul 14 20:32:50 2020
New Revision: 363194
URL: https://svnweb.freebsd.org/changeset/base/363194

Log:
  Improve the error handling in generating ASCONF chunks.
  In case of errors, the cleanup was not consistent.
  Thanks to Felix Weinrank for fuzzing the userland stack and making
  me aware of the issue.
  
  MFC after:1 week

Modified:
  head/sys/netinet/sctp_asconf.c
  head/sys/netinet/sctp_input.c

Modified: head/sys/netinet/sctp_asconf.c
==
--- head/sys/netinet/sctp_asconf.c  Tue Jul 14 20:23:27 2020
(r363193)
+++ head/sys/netinet/sctp_asconf.c  Tue Jul 14 20:32:50 2020
(r363194)
@@ -2587,14 +2587,14 @@ sctp_compose_asconf(struct sctp_tcb *stcb, int *retlen
if (m_asconf_chk == NULL) {
/* no mbuf's */
SCTPDBG(SCTP_DEBUG_ASCONF1,
-   "compose_asconf: couldn't get chunk mbuf!\n");
+   "sctp_compose_asconf: couldn't get chunk mbuf!\n");
return (NULL);
}
m_asconf = sctp_get_mbuf_for_msg(MCLBYTES, 0, M_NOWAIT, 1, MT_DATA);
if (m_asconf == NULL) {
/* no mbuf's */
SCTPDBG(SCTP_DEBUG_ASCONF1,
-   "compose_asconf: couldn't get mbuf!\n");
+   "sctp_compose_asconf: couldn't get mbuf!\n");
sctp_m_freem(m_asconf_chk);
return (NULL);
}
@@ -2719,10 +2719,12 @@ sctp_compose_asconf(struct sctp_tcb *stcb, int *retlen
break;
 #endif
default:
-   p_size = 0;
-   addr_size = 0;
-   addr_ptr = NULL;
-   break;
+   SCTPDBG(SCTP_DEBUG_ASCONF1,
+   "sctp_compose_asconf: no usable lookup addr 
(family = %d)!\n",
+   found_addr->sa_family);
+   sctp_m_freem(m_asconf_chk);
+   sctp_m_freem(m_asconf);
+   return (NULL);
}
lookup->ph.param_length = htons(SCTP_SIZE32(p_size));
memcpy(lookup->addr, addr_ptr, addr_size);
@@ -2730,12 +2732,10 @@ sctp_compose_asconf(struct sctp_tcb *stcb, int *retlen
} else {
/* uh oh... don't have any address?? */
SCTPDBG(SCTP_DEBUG_ASCONF1,
-   "compose_asconf: no lookup addr!\n");
-   /* XXX for now, we send a IPv4 address of 0.0.0.0 */
-   lookup->ph.param_type = htons(SCTP_IPV4_ADDRESS);
-   lookup->ph.param_length = 
htons(SCTP_SIZE32(sizeof(struct sctp_ipv4addr_param)));
-   memset(lookup->addr, 0, sizeof(struct in_addr));
-   SCTP_BUF_LEN(m_asconf_chk) += SCTP_SIZE32(sizeof(struct 
sctp_ipv4addr_param));
+   "sctp_compose_asconf: no lookup addr!\n");
+   sctp_m_freem(m_asconf_chk);
+   sctp_m_freem(m_asconf);
+   return (NULL);
}
}
/* chain it all together */
@@ -3261,10 +3261,9 @@ sctp_addr_mgmt_ep_sa(struct sctp_inpcb *inp, struct so
 }
 
 void
-sctp_asconf_send_nat_state_update(struct sctp_tcb *stcb,
-struct sctp_nets *net)
+sctp_asconf_send_nat_state_update(struct sctp_tcb *stcb, struct sctp_nets *net)
 {
-   struct sctp_asconf_addr *aa;
+   struct sctp_asconf_addr *aa_vtag, *aa_add, *aa_del;
struct sctp_ifa *sctp_ifap;
struct sctp_asconf_tag_param *vtag;
 #ifdef INET
@@ -3273,6 +3272,7 @@ sctp_asconf_send_nat_state_update(struct sctp_tcb *stc
 #ifdef INET6
struct sockaddr_in6 *to6;
 #endif
+
if (net == NULL) {
SCTPDBG(SCTP_DEBUG_ASCONF1, "sctp_asconf_send_nat_state_update: 
Missing net\n");
return;
@@ -3282,105 +3282,81 @@ sctp_asconf_send_nat_state_update(struct sctp_tcb *stc
return;
}
/*
-* Need to have in the asconf: - vtagparam(my_vtag/peer_vtag) -
-* add(0.0.0.0) - del(0.0.0.0) - Any global addresses add(addr)
+* Need to have in the ASCONF: - VTAG(my_vtag/peer_vtag) -
+* ADD(wildcard) - DEL(wildcard) - ADD(Any global addresses)
 */
-   SCTP_MALLOC(aa, struct sctp_asconf_addr *, sizeof(*aa),
-   SCTP_M_ASC_ADDR);
-   if (aa == NULL) {
-   /* didn't get memory */
-   SCTPDBG(SCTP_DEBUG_ASCONF1,
-   "sctp_asconf_send_nat_state_update: failed to get 
memory!\n");
+   SCTP_MALLOC(aa_vtag, struct sctp_asconf_addr *, sizeof(struct 
sctp_asconf_addr), SCTP_M_ASC_ADDR);
+   SCTP_MALLOC(aa_add, struct sctp_asconf_addr *, sizeof(struct 

svn commit: r363133 - head/sys/netinet

2020-07-12 Thread Michael Tuexen
Author: tuexen
Date: Sun Jul 12 18:34:09 2020
New Revision: 363133
URL: https://svnweb.freebsd.org/changeset/base/363133

Log:
  Cleanup, no functional change intended.
  
  This file is only compiled if INET or INET6 is defined. So there
  is no need for checking that.
  
  Reviewed by:  markj
  Differential Revision:https://reviews.freebsd.org/D25635

Modified:
  head/sys/netinet/sctp_syscalls.c

Modified: head/sys/netinet/sctp_syscalls.c
==
--- head/sys/netinet/sctp_syscalls.cSun Jul 12 17:16:57 2020
(r363132)
+++ head/sys/netinet/sctp_syscalls.cSun Jul 12 18:34:09 2020
(r363133)
@@ -32,8 +32,6 @@
 __FBSDID("$FreeBSD$");
 
 #include "opt_capsicum.h"
-#include "opt_inet.h"
-#include "opt_inet6.h"
 #include "opt_sctp.h"
 #include "opt_ktrace.h"
 
@@ -139,8 +137,6 @@ sctp_syscalls_uninit(void)
 
 /*
  * SCTP syscalls.
- * Functionality only compiled in if SCTP is defined in the kernel Makefile,
- * otherwise all return EOPNOTSUPP.
  */
 int
 sys_sctp_peeloff(td, uap)
@@ -150,7 +146,6 @@ sys_sctp_peeloff(td, uap)
caddr_t name;
} */ *uap;
 {
-#if defined(INET) || defined(INET6)
struct file *headfp, *nfp = NULL;
struct socket *head, *so;
cap_rights_t rights;
@@ -212,7 +207,6 @@ done:
fdrop(headfp, td);
 done2:
return (error);
-#endif
 }
 
 int
@@ -228,7 +222,6 @@ sys_sctp_generic_sendmsg (td, uap)
int flags
} */ *uap;
 {
-#if defined(INET) || defined(INET6)
struct sctp_sndrcvinfo sinfo, *u_sinfo = NULL;
struct socket *so;
struct file *fp = NULL;
@@ -323,7 +316,6 @@ sctp_bad:
 sctp_bad2:
free(to, M_SONAME);
return (error);
-#endif
 }
 
 int
@@ -339,7 +331,6 @@ sys_sctp_generic_sendmsg_iov(td, uap)
int flags
} */ *uap;
 {
-#if defined(INET) || defined(INET6)
struct sctp_sndrcvinfo sinfo, *u_sinfo = NULL;
struct socket *so;
struct file *fp = NULL;
@@ -451,7 +442,6 @@ sctp_bad1:
 sctp_bad2:
free(to, M_SONAME);
return (error);
-#endif
 }
 
 int
@@ -467,7 +457,6 @@ sys_sctp_generic_recvmsg(td, uap)
int *msg_flags
} */ *uap;
 {
-#if defined(INET) || defined(INET6)
uint8_t sockbufstore[256];
struct uio auio;
struct iovec *iov, *tiov;
@@ -597,5 +586,4 @@ out1:
fdrop(fp, td);
 
return (error);
-#endif
 }
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r363129 - head/sys/netinet

2020-07-12 Thread Michael Tuexen
Author: tuexen
Date: Sun Jul 12 14:50:12 2020
New Revision: 363129
URL: https://svnweb.freebsd.org/changeset/base/363129

Log:
  (Re)activate SCTP system calls when compiling SCTP support into the kernel
  r363079 introduced the possibility of loading the SCTP stack as a module in
  addition to compiling it into the kernel. As part of this, the registration
  of the system calls was removed and put into the loading of the module.
  Therefore, the system calls are not registered anymore when compiling the
  SCTP into the kernel. This patch addresses that.
  
  Reviewed by:  markj
  Differential Revision:https://reviews.freebsd.org/D25632

Modified:
  head/sys/netinet/sctp_syscalls.c

Modified: head/sys/netinet/sctp_syscalls.c
==
--- head/sys/netinet/sctp_syscalls.cSun Jul 12 11:24:23 2020
(r363128)
+++ head/sys/netinet/sctp_syscalls.cSun Jul 12 14:50:12 2020
(r363129)
@@ -117,6 +117,10 @@ sctp_syscalls_init(void)
return (0);
 }
 
+#ifdef SCTP
+SYSINIT(sctp_syscalls, SI_SUB_SYSCALLS, SI_ORDER_ANY, sctp_syscalls_init, 
NULL);
+#endif
+
 int
 sctp_syscalls_uninit(void)
 {
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r363080 - head/sys/netinet

2020-07-10 Thread Michael Tuexen
Author: tuexen
Date: Fri Jul 10 16:59:06 2020
New Revision: 363080
URL: https://svnweb.freebsd.org/changeset/base/363080

Log:
  Whitespace changes due to upstreaming r363079.

Modified:
  head/sys/netinet/sctp_os_bsd.h
  head/sys/netinet/sctp_usrreq.c

Modified: head/sys/netinet/sctp_os_bsd.h
==
--- head/sys/netinet/sctp_os_bsd.h  Fri Jul 10 14:56:05 2020
(r363079)
+++ head/sys/netinet/sctp_os_bsd.h  Fri Jul 10 16:59:06 2020
(r363080)
@@ -479,7 +479,7 @@ sctp_get_mbuf_for_msg(unsigned int space_needed,
 
 #define SCTP_IS_LISTENING(inp) ((inp->sctp_flags & SCTP_PCB_FLAGS_ACCEPTING) 
!= 0)
 
-intsctp_syscalls_init(void);
-intsctp_syscalls_uninit(void);
+int sctp_syscalls_init(void);
+int sctp_syscalls_uninit(void);
 
 #endif

Modified: head/sys/netinet/sctp_usrreq.c
==
--- head/sys/netinet/sctp_usrreq.c  Fri Jul 10 14:56:05 2020
(r363079)
+++ head/sys/netinet/sctp_usrreq.c  Fri Jul 10 16:59:06 2020
(r363080)
@@ -100,6 +100,7 @@ sctp_finish(void *unused __unused)
EVENTHANDLER_DEREGISTER(rt_addrmsg, SCTP_BASE_VAR(eh_tag));
sctp_pcb_finish();
 }
+
 VNET_SYSUNINIT(sctp, SI_SUB_PROTO_DOMAIN, SI_ORDER_FOURTH, sctp_finish, NULL);
 #endif
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r363076 - head/sys/netinet

2020-07-10 Thread Michael Tuexen
Author: tuexen
Date: Fri Jul 10 11:15:10 2020
New Revision: 363076
URL: https://svnweb.freebsd.org/changeset/base/363076

Log:
  Fix a use-after-free bug for the userland stack. The kernel
  stack is not affected.
  Thanks to Mark Wodrich from Google for finding and reporting the
  bug.
  
  MFC after:1 week

Modified:
  head/sys/netinet/sctp_indata.c

Modified: head/sys/netinet/sctp_indata.c
==
--- head/sys/netinet/sctp_indata.c  Fri Jul 10 11:01:05 2020
(r363075)
+++ head/sys/netinet/sctp_indata.c  Fri Jul 10 11:15:10 2020
(r363076)
@@ -1700,6 +1700,7 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struc
 int *break_flag, int last_chunk, uint8_t chk_type)
 {
struct sctp_tmit_chunk *chk = NULL; /* make gcc happy */
+   struct sctp_stream_in *strm;
uint32_t tsn, fsn, gap, mid;
struct mbuf *dmbuf;
int the_len;
@@ -2327,12 +2328,13 @@ finish_express_del:
/* All can be removed */
TAILQ_FOREACH_SAFE(control, >pending_reply_queue, 
next, ncontrol) {
TAILQ_REMOVE(>pending_reply_queue, 
control, next);
+   strm = >strmin[control->sinfo_stream];
sctp_queue_data_to_stream(stcb, asoc, control, 
abort_flag, _reasm_check);
if (*abort_flag) {
return (0);
}
if (need_reasm_check) {
-   (void)sctp_deliver_reasm_check(stcb, 
asoc, >strmin[control->sinfo_stream], SCTP_READ_LOCK_NOT_HELD);
+   (void)sctp_deliver_reasm_check(stcb, 
asoc, strm, SCTP_READ_LOCK_NOT_HELD);
need_reasm_check = 0;
}
}
@@ -2347,12 +2349,13 @@ finish_express_del:
 * control->sinfo_tsn > liste->tsn
 */
TAILQ_REMOVE(>pending_reply_queue, 
control, next);
+   strm = >strmin[control->sinfo_stream];
sctp_queue_data_to_stream(stcb, asoc, control, 
abort_flag, _reasm_check);
if (*abort_flag) {
return (0);
}
if (need_reasm_check) {
-   (void)sctp_deliver_reasm_check(stcb, 
asoc, >strmin[control->sinfo_stream], SCTP_READ_LOCK_NOT_HELD);
+   (void)sctp_deliver_reasm_check(stcb, 
asoc, strm, SCTP_READ_LOCK_NOT_HELD);
need_reasm_check = 0;
}
}
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r363046 - head/sys/netinet

2020-07-09 Thread Michael Tuexen
Author: tuexen
Date: Thu Jul  9 16:18:42 2020
New Revision: 363046
URL: https://svnweb.freebsd.org/changeset/base/363046

Log:
  Optimize flushing of receive queues.
  This addresses an issue found and reported for the userland stack in
  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=21243
  
  MFC after:1 week

Modified:
  head/sys/netinet/sctp_indata.c

Modified: head/sys/netinet/sctp_indata.c
==
--- head/sys/netinet/sctp_indata.c  Thu Jul  9 14:42:41 2020
(r363045)
+++ head/sys/netinet/sctp_indata.c  Thu Jul  9 16:18:42 2020
(r363046)
@@ -5411,11 +5411,9 @@ sctp_kick_prsctp_reorder_queue(struct sctp_tcb *stcb,
 
 static void
 sctp_flush_reassm_for_str_seq(struct sctp_tcb *stcb,
-struct sctp_association *asoc,
-uint16_t stream, uint32_t mid, int ordered, uint32_t cumtsn)
+struct sctp_association *asoc, struct sctp_stream_in *strm,
+struct sctp_queued_to_read *control, int ordered, uint32_t cumtsn)
 {
-   struct sctp_queued_to_read *control;
-   struct sctp_stream_in *strm;
struct sctp_tmit_chunk *chk, *nchk;
int cnt_removed = 0;
 
@@ -5427,12 +5425,6 @@ sctp_flush_reassm_for_str_seq(struct sctp_tcb *stcb,
 * it can be delivered... But for now we just dump everything on the
 * queue.
 */
-   strm = >strmin[stream];
-   control = sctp_find_reasm_entry(strm, mid, ordered, 
asoc->idata_supported);
-   if (control == NULL) {
-   /* Not found */
-   return;
-   }
if (!asoc->idata_supported && !ordered && 
SCTP_TSN_GT(control->fsn_included, cumtsn)) {
return;
}
@@ -5609,7 +5601,10 @@ sctp_handle_forward_tsn(struct sctp_tcb *stcb,
/* Flush all the un-ordered data based on cum-tsn */
SCTP_INP_READ_LOCK(stcb->sctp_ep);
for (sid = 0; sid < asoc->streamincnt; sid++) {
-   sctp_flush_reassm_for_str_seq(stcb, asoc, sid, 0, 0, 
new_cum_tsn);
+   strm = >strmin[sid];
+   if (!TAILQ_EMPTY(>uno_inqueue)) {
+   sctp_flush_reassm_for_str_seq(stcb, asoc, strm, 
TAILQ_FIRST(>uno_inqueue), 0, new_cum_tsn);
+   }
}
SCTP_INP_READ_UNLOCK(stcb->sctp_ep);
}
@@ -5621,7 +5616,7 @@ sctp_handle_forward_tsn(struct sctp_tcb *stcb,
if (m && fwd_sz) {
/* New method. */
unsigned int num_str;
-   uint32_t mid, cur_mid;
+   uint32_t mid;
uint16_t sid;
uint16_t ordered, flags;
struct sctp_strseq *stseq, strseqbuf;
@@ -5688,8 +5683,24 @@ sctp_handle_forward_tsn(struct sctp_tcb *stcb,
asoc->fragmented_delivery_inprogress = 0;
}
strm = >strmin[sid];
-   for (cur_mid = strm->last_mid_delivered; 
SCTP_MID_GE(asoc->idata_supported, mid, cur_mid); cur_mid++) {
-   sctp_flush_reassm_for_str_seq(stcb, asoc, sid, 
cur_mid, ordered, new_cum_tsn);
+   if (ordered) {
+   TAILQ_FOREACH(control, >inqueue, 
next_instrm) {
+   if (SCTP_MID_GE(asoc->idata_supported, 
mid, control->mid)) {
+   
sctp_flush_reassm_for_str_seq(stcb, asoc, strm, control, ordered, new_cum_tsn);
+   }
+   }
+   } else {
+   if (asoc->idata_supported) {
+   TAILQ_FOREACH(control, 
>uno_inqueue, next_instrm) {
+   if 
(SCTP_MID_GE(asoc->idata_supported, mid, control->mid)) {
+   
sctp_flush_reassm_for_str_seq(stcb, asoc, strm, control, ordered, new_cum_tsn);
+   }
+   }
+   } else {
+   if (!TAILQ_EMPTY(>uno_inqueue)) {
+   
sctp_flush_reassm_for_str_seq(stcb, asoc, strm, 
TAILQ_FIRST(>uno_inqueue), ordered, new_cum_tsn);
+   }
+   }
}
TAILQ_FOREACH(control, >sctp_ep->read_queue, 
next) {
if ((control->sinfo_stream == sid) &&
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r363012 - head/sys/netinet

2020-07-08 Thread Michael Tuexen
Author: tuexen
Date: Wed Jul  8 16:23:40 2020
New Revision: 363012
URL: https://svnweb.freebsd.org/changeset/base/363012

Log:
  Improve consistency.
  
  MFC after:1 week

Modified:
  head/sys/netinet/sctp_input.c

Modified: head/sys/netinet/sctp_input.c
==
--- head/sys/netinet/sctp_input.c   Wed Jul  8 16:04:06 2020
(r363011)
+++ head/sys/netinet/sctp_input.c   Wed Jul  8 16:23:40 2020
(r363012)
@@ -5103,8 +5103,8 @@ process_control_chunks:
if (stcb->asoc.prsctp_supported == 0) {
goto unknown_chunk;
}
-   if (((asoc->idata_supported == 1) && 
(ch->chunk_type == SCTP_FORWARD_CUM_TSN)) ||
-   ((asoc->idata_supported == 0) && 
(ch->chunk_type == SCTP_IFORWARD_CUM_TSN))) {
+   if (((stcb->asoc.idata_supported == 1) && 
(ch->chunk_type == SCTP_FORWARD_CUM_TSN)) ||
+   ((stcb->asoc.idata_supported == 0) && 
(ch->chunk_type == SCTP_IFORWARD_CUM_TSN))) {
if (ch->chunk_type == 
SCTP_FORWARD_CUM_TSN) {
SCTP_SNPRINTF(msg, sizeof(msg), 
"%s", "FORWARD-TSN chunk received when I-FORWARD-TSN was negotiated");
} else {
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r363011 - head/sys/netinet

2020-07-08 Thread Michael Tuexen
Author: tuexen
Date: Wed Jul  8 16:04:06 2020
New Revision: 363011
URL: https://svnweb.freebsd.org/changeset/base/363011

Log:
  Fix error description.
  
  MFC after:1 week

Modified:
  head/sys/netinet/sctp_indata.c

Modified: head/sys/netinet/sctp_indata.c
==
--- head/sys/netinet/sctp_indata.c  Wed Jul  8 15:49:30 2020
(r363010)
+++ head/sys/netinet/sctp_indata.c  Wed Jul  8 16:04:06 2020
(r363011)
@@ -2745,7 +2745,7 @@ sctp_process_data(struct mbuf **mm, int iphlen, int *o
struct mbuf *op_err;
char msg[SCTP_DIAG_INFO_LEN];
 
-   SCTP_SNPRINTF(msg, sizeof(msg), "%s", "I-DATA chunk 
received when DATA was negotiated");
+   SCTP_SNPRINTF(msg, sizeof(msg), "%s", "DATA chunk 
received when I-DATA was negotiated");
op_err = 
sctp_generate_cause(SCTP_CAUSE_PROTOCOL_VIOLATION, msg);
stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_INDATA 
+ SCTP_LOC_20;
sctp_abort_an_association(inp, stcb, op_err, 
SCTP_SO_NOT_LOCKED);
@@ -2756,7 +2756,7 @@ sctp_process_data(struct mbuf **mm, int iphlen, int *o
struct mbuf *op_err;
char msg[SCTP_DIAG_INFO_LEN];
 
-   SCTP_SNPRINTF(msg, sizeof(msg), "%s", "DATA chunk 
received when I-DATA was negotiated");
+   SCTP_SNPRINTF(msg, sizeof(msg), "%s", "I-DATA chunk 
received when DATA was negotiated");
op_err = 
sctp_generate_cause(SCTP_CAUSE_PROTOCOL_VIOLATION, msg);
stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_INDATA 
+ SCTP_LOC_21;
sctp_abort_an_association(inp, stcb, op_err, 
SCTP_SO_NOT_LOCKED);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r363010 - head/sys/netinet

2020-07-08 Thread Michael Tuexen
Author: tuexen
Date: Wed Jul  8 15:49:30 2020
New Revision: 363010
URL: https://svnweb.freebsd.org/changeset/base/363010

Log:
  Don't accept FORWARD-TSN chunks when I-FORWARD-TSN was negotiated
  and vice versa.
  
  MFC after:1 week

Modified:
  head/sys/netinet/sctp_input.c

Modified: head/sys/netinet/sctp_input.c
==
--- head/sys/netinet/sctp_input.c   Wed Jul  8 13:40:27 2020
(r363009)
+++ head/sys/netinet/sctp_input.c   Wed Jul  8 15:49:30 2020
(r363010)
@@ -5089,7 +5089,8 @@ process_control_chunks:
break;
case SCTP_FORWARD_CUM_TSN:
case SCTP_IFORWARD_CUM_TSN:
-   SCTPDBG(SCTP_DEBUG_INPUT3, "SCTP_FWD_TSN\n");
+   SCTPDBG(SCTP_DEBUG_INPUT3, "%s\n",
+   ch->chunk_type == SCTP_FORWARD_CUM_TSN ? 
"FORWARD_TSN" : "I_FORWARD_TSN");
if (chk_length < sizeof(struct sctp_forward_tsn_chunk)) 
{
/* Its not ours */
*offset = length;
@@ -5101,6 +5102,18 @@ process_control_chunks:
 
if (stcb->asoc.prsctp_supported == 0) {
goto unknown_chunk;
+   }
+   if (((asoc->idata_supported == 1) && 
(ch->chunk_type == SCTP_FORWARD_CUM_TSN)) ||
+   ((asoc->idata_supported == 0) && 
(ch->chunk_type == SCTP_IFORWARD_CUM_TSN))) {
+   if (ch->chunk_type == 
SCTP_FORWARD_CUM_TSN) {
+   SCTP_SNPRINTF(msg, sizeof(msg), 
"%s", "FORWARD-TSN chunk received when I-FORWARD-TSN was negotiated");
+   } else {
+   SCTP_SNPRINTF(msg, sizeof(msg), 
"%s", "I-FORWARD-TSN chunk received when FORWARD-TSN was negotiated");
+   }
+   op_err = 
sctp_generate_cause(SCTP_CAUSE_PROTOCOL_VIOLATION, msg);
+   sctp_abort_an_association(inp, stcb, 
op_err, SCTP_SO_NOT_LOCKED);
+   *offset = length;
+   return (NULL);
}
*fwd_tsn_seen = 1;
if (inp->sctp_flags & 
SCTP_PCB_FLAGS_SOCKET_GONE) {
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r363008 - head/sys/netinet

2020-07-08 Thread Michael Tuexen
Author: tuexen
Date: Wed Jul  8 12:25:19 2020
New Revision: 363008
URL: https://svnweb.freebsd.org/changeset/base/363008

Log:
  Improve handling of PKTDROP chunks. This includes the input validation
  to address two issues found by ossfuzz testing the userland stack:
  * https://oss-fuzz.com/testcase-detail/5387560242380800
  * https://oss-fuzz.com/testcase-detail/4887954068865024
  and adding support for I-DATA chunks in addition to DATA chunks.

Modified:
  head/sys/netinet/sctp_input.c

Modified: head/sys/netinet/sctp_input.c
==
--- head/sys/netinet/sctp_input.c   Wed Jul  8 10:04:51 2020
(r363007)
+++ head/sys/netinet/sctp_input.c   Wed Jul  8 12:25:19 2020
(r363008)
@@ -3046,7 +3046,8 @@ process_chunk_drop(struct sctp_tcb *stcb, struct sctp_
 {
switch (desc->chunk_type) {
case SCTP_DATA:
-   /* find the tsn to resend (possibly */
+   case SCTP_IDATA:
+   /* find the tsn to resend (possibly) */
{
uint32_t tsn;
struct sctp_tmit_chunk *tp1;
@@ -3080,8 +3081,6 @@ process_chunk_drop(struct sctp_tcb *stcb, struct sctp_
SCTP_STAT_INCR(sctps_pdrptsnnf);
}
if ((tp1) && (tp1->sent < SCTP_DATAGRAM_ACKED)) {
-   uint8_t *ddp;
-
if (((flg & SCTP_BADCRC) == 0) &&
((flg & SCTP_FROM_MIDDLE_BOX) == 0)) {
return (0);
@@ -3096,20 +3095,18 @@ process_chunk_drop(struct sctp_tcb *stcb, struct sctp_
SCTP_STAT_INCR(sctps_pdrpdizrw);
return (0);
}
-   ddp = (uint8_t *)(mtod(tp1->data, caddr_t)+
-   sizeof(struct sctp_data_chunk));
-   {
-   unsigned int iii;
-
-   for (iii = 0; iii < 
sizeof(desc->data_bytes);
-   iii++) {
-   if (ddp[iii] != 
desc->data_bytes[iii]) {
-   
SCTP_STAT_INCR(sctps_pdrpbadd);
-   return (-1);
-   }
-   }
+   if ((uint32_t)SCTP_BUF_LEN(tp1->data) <
+   SCTP_DATA_CHUNK_OVERHEAD(stcb) + 
SCTP_NUM_DB_TO_VERIFY) {
+   /* Payload not matching. */
+   SCTP_STAT_INCR(sctps_pdrpbadd);
+   return (-1);
}
-
+   if (memcmp(mtod(tp1->data, 
caddr_t)+SCTP_DATA_CHUNK_OVERHEAD(stcb),
+   desc->data_bytes, SCTP_NUM_DB_TO_VERIFY) != 
0) {
+   /* Payload not matching. */
+   SCTP_STAT_INCR(sctps_pdrpbadd);
+   return (-1);
+   }
if (tp1->do_rtt) {
/*
 * this guy had a RTO calculation
@@ -4135,104 +4132,126 @@ static void
 sctp_handle_packet_dropped(struct sctp_pktdrop_chunk *cp,
 struct sctp_tcb *stcb, struct sctp_nets *net, uint32_t limit)
 {
+   struct sctp_chunk_desc desc;
+   struct sctp_chunkhdr *chk_hdr;
+   struct sctp_data_chunk *data_chunk;
+   struct sctp_idata_chunk *idata_chunk;
uint32_t bottle_bw, on_queue;
+   uint32_t offset, chk_len;
uint16_t trunc_len;
-   unsigned int chlen;
-   unsigned int at;
-   struct sctp_chunk_desc desc;
-   struct sctp_chunkhdr *ch;
+   uint16_t pktdrp_len;
+   uint8_t pktdrp_flags;
 
-   chlen = ntohs(cp->ch.chunk_length);
-   chlen -= sizeof(struct sctp_pktdrop_chunk);
-   /* XXX possible chlen underflow */
-   if (chlen == 0) {
-   ch = NULL;
-   if (cp->ch.chunk_flags & SCTP_FROM_MIDDLE_BOX)
+   KASSERT(sizeof(struct sctp_pktdrop_chunk) <= limit,
+   ("PKTDROP chunk too small"));
+   pktdrp_flags = cp->ch.chunk_flags;
+   pktdrp_len = ntohs(cp->ch.chunk_length);
+   KASSERT(limit <= pktdrp_len, ("Inconsistent limit"));
+   if (pktdrp_flags & SCTP_PACKET_TRUNCATED) {
+   trunc_len = ntohs(cp->trunc_len);
+   if (trunc_len <= pktdrp_len - sizeof(struct 
sctp_pktdrop_chunk)) {
+   /* The peer plays games with us. */
+   return;
+   

svn commit: r362846 - head/sys/netinet/tcp_stacks

2020-07-01 Thread Michael Tuexen
Author: tuexen
Date: Wed Jul  1 17:17:06 2020
New Revision: 362846
URL: https://svnweb.freebsd.org/changeset/base/362846

Log:
  Fix the cleanup handling in a error path for TCP BBR.
  
  Reported by:  syzbot+df7899c55c4cc52f5...@syzkaller.appspotmail.com
  Reviewed by:  rscheff
  Sponsored by: Netflix, Inc.
  Differential Revision:https://reviews.freebsd.org/D25486

Modified:
  head/sys/netinet/tcp_stacks/bbr.c

Modified: head/sys/netinet/tcp_stacks/bbr.c
==
--- head/sys/netinet/tcp_stacks/bbr.c   Wed Jul  1 16:57:57 2020
(r362845)
+++ head/sys/netinet/tcp_stacks/bbr.c   Wed Jul  1 17:17:06 2020
(r362846)
@@ -13381,6 +13381,8 @@ send:
 */
BBR_STAT_INC(bbr_offset_drop);
tcp_set_inp_to_drop(inp, EFAULT);
+   SOCKBUF_UNLOCK(sb);
+   (void)m_free(m);
return (0);
}
len = rsm->r_end - rsm->r_start;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r362813 - head/sys/netinet

2020-06-30 Thread Michael Tuexen
Author: tuexen
Date: Tue Jun 30 21:50:05 2020
New Revision: 362813
URL: https://svnweb.freebsd.org/changeset/base/362813

Log:
  Fix a bug introduced in https://svnweb.freebsd.org/changeset/base/362173
  
  Reported by:  syzbot+f3a6fccfa6ae9d3de...@syzkaller.appspotmail.com
  MFC after:1 week

Modified:
  head/sys/netinet/sctputil.c

Modified: head/sys/netinet/sctputil.c
==
--- head/sys/netinet/sctputil.c Tue Jun 30 21:48:58 2020(r362812)
+++ head/sys/netinet/sctputil.c Tue Jun 30 21:50:05 2020(r362813)
@@ -5247,7 +5247,11 @@ sctp_find_ifa_in_ep(struct sctp_inpcb *inp, struct soc
if (holds_lock == 0) {
SCTP_INP_RUNLOCK(inp);
}
-   return (laddr->ifa);
+   if (laddr != NULL) {
+   return (laddr->ifa);
+   } else {
+   return (NULL);
+   }
 }
 
 uint32_t
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r362722 - head/sys/netinet

2020-06-28 Thread Michael Tuexen
Author: tuexen
Date: Sun Jun 28 14:11:36 2020
New Revision: 362722
URL: https://svnweb.freebsd.org/changeset/base/362722

Log:
  Don't send packets containing ERROR chunks in response to unknown
  chunks when being in a state where the verification tag to be used
  is not known yet.
  
  MFC after:1 week

Modified:
  head/sys/netinet/sctp_input.c

Modified: head/sys/netinet/sctp_input.c
==
--- head/sys/netinet/sctp_input.c   Sun Jun 28 14:02:49 2020
(r362721)
+++ head/sys/netinet/sctp_input.c   Sun Jun 28 14:11:36 2020
(r362722)
@@ -5178,7 +5178,11 @@ process_control_chunks:
default:
unknown_chunk:
/* it's an unknown chunk! */
-   if ((ch->chunk_type & 0x40) && (stcb != NULL)) {
+   if ((ch->chunk_type & 0x40) &&
+   (stcb != NULL) &&
+   (SCTP_GET_STATE(stcb) != SCTP_STATE_EMPTY) &&
+   (SCTP_GET_STATE(stcb) != SCTP_STATE_INUSE) &&
+   (SCTP_GET_STATE(stcb) != SCTP_STATE_COOKIE_WAIT)) {
struct sctp_gen_error_cause *cause;
int len;
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r362720 - head/sys/netinet

2020-06-28 Thread Michael Tuexen
Author: tuexen
Date: Sun Jun 28 11:12:03 2020
New Revision: 362720
URL: https://svnweb.freebsd.org/changeset/base/362720

Log:
  Don't check ch for not being NULL, since that is true.
  
  MFC after:1 week

Modified:
  head/sys/netinet/sctp_input.c

Modified: head/sys/netinet/sctp_input.c
==
--- head/sys/netinet/sctp_input.c   Sun Jun 28 07:43:43 2020
(r362719)
+++ head/sys/netinet/sctp_input.c   Sun Jun 28 11:12:03 2020
(r362720)
@@ -5106,7 +5106,7 @@ process_control_chunks:
break;
case SCTP_STREAM_RESET:
SCTPDBG(SCTP_DEBUG_INPUT3, "SCTP_STREAM_RESET\n");
-   if (((stcb == NULL) || (ch == NULL) || (chk_length < 
sizeof(struct sctp_stream_reset_tsn_req {
+   if ((stcb == NULL) || (chk_length < sizeof(struct 
sctp_stream_reset_tsn_req))) {
/* Its not ours */
*offset = length;
return (stcb);
@@ -5129,7 +5129,7 @@ process_control_chunks:
return (stcb);
}
 
-   if ((ch != NULL) && (stcb != NULL) && (netp != NULL) && 
(*netp != NULL)) {
+   if ((stcb != NULL) && (netp != NULL) && (*netp != 
NULL)) {
if (stcb->asoc.pktdrop_supported == 0) {
goto unknown_chunk;
}
@@ -5165,8 +5165,7 @@ process_control_chunks:
goto next_chunk;
}
got_auth = 1;
-   if ((ch == NULL) || sctp_handle_auth(stcb, (struct 
sctp_auth_chunk *)ch,
-   m, *offset)) {
+   if (sctp_handle_auth(stcb, (struct sctp_auth_chunk 
*)ch, m, *offset)) {
/* auth HMAC failed so dump the packet */
*offset = length;
return (stcb);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r362581 - head/sys/netinet

2020-06-24 Thread Michael Tuexen
Author: tuexen
Date: Wed Jun 24 14:47:51 2020
New Revision: 362581
URL: https://svnweb.freebsd.org/changeset/base/362581

Log:
  Fix the acconting for fragmented unordered messages when using
  interleaving.
  This was reported for the userland stack in
  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=19321
  
  MFC after:1 week

Modified:
  head/sys/netinet/sctp_indata.c

Modified: head/sys/netinet/sctp_indata.c
==
--- head/sys/netinet/sctp_indata.c  Wed Jun 24 13:52:53 2020
(r362580)
+++ head/sys/netinet/sctp_indata.c  Wed Jun 24 14:47:51 2020
(r362581)
@@ -,6 +,16 @@ sctp_deliver_reasm_check(struct sctp_tcb *stcb, struct
 #endif
SCTP_STAT_INCR_COUNTER64(sctps_reasmusrmsgs);
TAILQ_REMOVE(>uno_inqueue, control, 
next_instrm);
+   if (asoc->size_on_all_streams >= 
control->length) {
+   asoc->size_on_all_streams -= 
control->length;
+   } else {
+#ifdef INVARIANTS
+   panic("size_on_all_streams = %u smaller 
than control length %u", asoc->size_on_all_streams, control->length);
+#else
+   asoc->size_on_all_streams = 0;
+#endif
+   }
+   sctp_ucount_decr(asoc->cnt_on_all_streams);
control->on_strm_q = 0;
}
if (control->on_read_q == 0) {
@@ -1391,7 +1401,7 @@ sctp_queue_data_for_reasm(struct sctp_tcb *stcb, struc
}
/* Must be added to the stream-in queue */
if (created_control) {
-   if (unordered == 0) {
+   if ((unordered == 0) || (asoc->idata_supported)) {
sctp_ucount_incr(asoc->cnt_on_all_streams);
}
if (sctp_place_control_in_stream(strm, asoc, control)) {
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r362563 - head/sys/netinet

2020-06-23 Thread Michael Tuexen
Author: tuexen
Date: Tue Jun 23 23:05:05 2020
New Revision: 362563
URL: https://svnweb.freebsd.org/changeset/base/362563

Log:
  Fix alignment issue manifesting in the userland stack.
  
  MFC after:1 wwek

Modified:
  head/sys/netinet/sctp_usrreq.c

Modified: head/sys/netinet/sctp_usrreq.c
==
--- head/sys/netinet/sctp_usrreq.c  Tue Jun 23 22:47:54 2020
(r362562)
+++ head/sys/netinet/sctp_usrreq.c  Tue Jun 23 23:05:05 2020
(r362563)
@@ -989,15 +989,15 @@ sctp_shutdown(struct socket *so)
  * returns 0 on success, 1 on error
  */
 static uint32_t
-sctp_fill_user_address(union sctp_sockstore *ss, struct sockaddr *sa)
+sctp_fill_user_address(struct sockaddr *dst, struct sockaddr *src)
 {
 #ifdef INET6
struct sockaddr_in6 lsa6;
 
-   sa = (struct sockaddr *)sctp_recover_scope((struct sockaddr_in6 *)sa,
+   src = (struct sockaddr *)sctp_recover_scope((struct sockaddr_in6 *)src,
);
 #endif
-   memcpy(ss, sa, sa->sa_len);
+   memcpy(dst, src, src->sa_len);
return (0);
 }
 
@@ -1010,7 +1010,7 @@ static size_t
 sctp_fill_up_addresses_vrf(struct sctp_inpcb *inp,
 struct sctp_tcb *stcb,
 size_t limit,
-union sctp_sockstore *addr,
+struct sockaddr *addr,
 uint32_t vrf_id)
 {
struct sctp_ifn *sctp_ifn;
@@ -1125,9 +1125,9 @@ sctp_fill_up_addresses_vrf(struct sctp_inpcb *inp,
if (actual + 
sizeof(struct sockaddr_in6) > limit) {
return (actual);
}
-   
in6_sin_2_v4mapsin6(sin, >sin6);
-   addr->sin6.sin6_port = 
inp->sctp_lport;
-   addr = (union 
sctp_sockstore *)((caddr_t)addr + sizeof(struct sockaddr_in6));
+   
in6_sin_2_v4mapsin6(sin, (struct sockaddr_in6 *));
+   ((struct sockaddr_in6 
*)addr)->sin6_port = inp->sctp_lport;
+   addr = (struct sockaddr 
*)((caddr_t)addr + sizeof(struct sockaddr_in6));
actual += sizeof(struct 
sockaddr_in6);
} else {
 #endif
@@ -1135,8 +1135,8 @@ sctp_fill_up_addresses_vrf(struct sctp_inpcb *inp,
return (actual);
}
memcpy(addr, sin, 
sizeof(struct sockaddr_in));
-   addr->sin.sin_port = 
inp->sctp_lport;
-   addr = (union 
sctp_sockstore *)((caddr_t)addr + sizeof(struct sockaddr_in));
+   ((struct sockaddr_in 
*)addr)->sin_port = inp->sctp_lport;
+   addr = (struct sockaddr 
*)((caddr_t)addr + sizeof(struct sockaddr_in));
actual += sizeof(struct 
sockaddr_in);
 #ifdef INET6
}
@@ -1189,8 +1189,8 @@ sctp_fill_up_addresses_vrf(struct sctp_inpcb *inp,
return (actual);
}
memcpy(addr, sin6, 
sizeof(struct sockaddr_in6));
-   addr->sin6.sin6_port = 
inp->sctp_lport;
-   addr = (union sctp_sockstore 
*)((caddr_t)addr + sizeof(struct sockaddr_in6));
+   ((struct sockaddr_in6 
*)addr)->sin6_port = inp->sctp_lport;
+   addr = (struct sockaddr 
*)((caddr_t)addr + sizeof(struct sockaddr_in6));
actual += sizeof(struct 
sockaddr_in6);
} else {
continue;
@@ -1222,19 +1222,19 @@ sctp_fill_up_addresses_vrf(struct sctp_inpcb *inp,
switch (laddr->ifa->address.sa.sa_family) {
 #ifdef INET
case AF_INET:
-   addr->sin.sin_port = inp->sctp_lport;
+   ((struct sockaddr_in *)addr)->sin_port = 
inp->sctp_lport;
break;
 #endif
 #ifdef INET6
case AF_INET6:
-   addr->sin6.sin6_port = inp->sctp_lport;
+   

svn commit: r362498 - head/sys/netinet

2020-06-22 Thread Michael Tuexen
Author: tuexen
Date: Mon Jun 22 14:36:14 2020
New Revision: 362498
URL: https://svnweb.freebsd.org/changeset/base/362498

Log:
  No need to include netinet/sctp_crc32.h twice.

Modified:
  head/sys/netinet/sctp_crc32.c

Modified: head/sys/netinet/sctp_crc32.c
==
--- head/sys/netinet/sctp_crc32.c   Mon Jun 22 14:01:31 2020
(r362497)
+++ head/sys/netinet/sctp_crc32.c   Mon Jun 22 14:36:14 2020
(r362498)
@@ -46,7 +46,6 @@ __FBSDID("$FreeBSD$");
 #include 
 #if defined(SCTP) || defined(SCTP_SUPPORT)
 #include 
-#include 
 #include 
 #endif
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r362474 - head/lib/libc/net

2020-06-21 Thread Michael Tuexen
Author: tuexen
Date: Sun Jun 21 23:47:27 2020
New Revision: 362474
URL: https://svnweb.freebsd.org/changeset/base/362474

Log:
  Add include missing from my last commit.

Modified:
  head/lib/libc/net/sctp_sys_calls.c

Modified: head/lib/libc/net/sctp_sys_calls.c
==
--- head/lib/libc/net/sctp_sys_calls.c  Sun Jun 21 23:12:56 2020
(r362473)
+++ head/lib/libc/net/sctp_sys_calls.c  Sun Jun 21 23:47:27 2020
(r362474)
@@ -36,6 +36,7 @@
 __FBSDID("$FreeBSD$");
 
 #include 
+#include 
 #include 
 #include 
 #include 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r362473 - in head: lib/libc/net sys/netinet

2020-06-21 Thread Michael Tuexen
Author: tuexen
Date: Sun Jun 21 23:12:56 2020
New Revision: 362473
URL: https://svnweb.freebsd.org/changeset/base/362473

Log:
  Cleanup the defintion of struct sctp_getaddresses. This stucture
  is used by the IPPROTO_SCTP level socket options SCTP_GET_PEER_ADDRESSES
  and SCTP_GET_LOCAL_ADDRESSES, which are used by libc to implement
  sctp_getladdrs() and sctp_getpaddrs().
  These changes allow an old libc to work on a newer kernel.

Modified:
  head/lib/libc/net/sctp_sys_calls.c
  head/sys/netinet/sctp_uio.h
  head/sys/netinet/sctp_usrreq.c

Modified: head/lib/libc/net/sctp_sys_calls.c
==
--- head/lib/libc/net/sctp_sys_calls.c  Sun Jun 21 22:09:30 2020
(r362472)
+++ head/lib/libc/net/sctp_sys_calls.c  Sun Jun 21 23:12:56 2020
(r362473)
@@ -406,7 +406,7 @@ sctp_getpaddrs(int sd, sctp_assoc_t id, struct sockadd
return (-1);
}
/* size required is returned in 'asoc' */
-   opt_len = (socklen_t)((size_t)asoc + sizeof(sctp_assoc_t));
+   opt_len = (socklen_t)((size_t)asoc + sizeof(struct sctp_getaddresses));
addrs = calloc(1, (size_t)opt_len);
if (addrs == NULL) {
errno = ENOMEM;
@@ -419,9 +419,9 @@ sctp_getpaddrs(int sd, sctp_assoc_t id, struct sockadd
free(addrs);
return (-1);
}
-   *raddrs = (struct sockaddr *)>addr[0];
+   *raddrs = >addr[0].sa;
cnt = 0;
-   sa = (struct sockaddr *)>addr[0];
+   sa = >addr[0].sa;
lim = (caddr_t)addrs + opt_len;
while (((caddr_t)sa < lim) && (sa->sa_len > 0)) {
sa = (struct sockaddr *)((caddr_t)sa + sa->sa_len);
@@ -436,7 +436,7 @@ sctp_freepaddrs(struct sockaddr *addrs)
void *fr_addr;
 
/* Take away the hidden association id */
-   fr_addr = (void *)((caddr_t)addrs - sizeof(sctp_assoc_t));
+   fr_addr = (void *)((caddr_t)addrs - offsetof(struct sctp_getaddresses, 
addr));
/* Now free it */
free(fr_addr);
 }
@@ -466,7 +466,7 @@ sctp_getladdrs(int sd, sctp_assoc_t id, struct sockadd
errno = ENOTCONN;
return (-1);
}
-   opt_len = (socklen_t)(size_of_addresses + sizeof(sctp_assoc_t));
+   opt_len = (socklen_t)(size_of_addresses + sizeof(struct 
sctp_getaddresses));
addrs = calloc(1, (size_t)opt_len);
if (addrs == NULL) {
errno = ENOMEM;
@@ -480,9 +480,9 @@ sctp_getladdrs(int sd, sctp_assoc_t id, struct sockadd
errno = ENOMEM;
return (-1);
}
-   *raddrs = (struct sockaddr *)>addr[0];
+   *raddrs = >addr[0].sa;
cnt = 0;
-   sa = (struct sockaddr *)>addr[0];
+   sa = >addr[0].sa;
lim = (caddr_t)addrs + opt_len;
while (((caddr_t)sa < lim) && (sa->sa_len > 0)) {
sa = (struct sockaddr *)((caddr_t)sa + sa->sa_len);
@@ -497,7 +497,7 @@ sctp_freeladdrs(struct sockaddr *addrs)
void *fr_addr;
 
/* Take away the hidden association id */
-   fr_addr = (void *)((caddr_t)addrs - sizeof(sctp_assoc_t));
+   fr_addr = (void *)((caddr_t)addrs - offsetof(struct sctp_getaddresses, 
addr));
/* Now free it */
free(fr_addr);
 }

Modified: head/sys/netinet/sctp_uio.h
==
--- head/sys/netinet/sctp_uio.h Sun Jun 21 22:09:30 2020(r362472)
+++ head/sys/netinet/sctp_uio.h Sun Jun 21 23:12:56 2020(r362473)
@@ -39,7 +39,7 @@ __FBSDID("$FreeBSD$");
 #define _NETINET_SCTP_UIO_H_
 
 
-#if ! defined(_KERNEL)
+#if !defined(_KERNEL)
 #include 
 #endif
 #include 
@@ -633,10 +633,15 @@ struct sctp_setpeerprim {
uint8_t sspp_padding[4];
 };
 
+union sctp_sockstore {
+   struct sockaddr_in sin;
+   struct sockaddr_in6 sin6;
+   struct sockaddr sa;
+};
+
 struct sctp_getaddresses {
sctp_assoc_t sget_assoc_id;
-   /* addr is filled in for N * sockaddr_storage */
-   struct sockaddr addr[1];
+   union sctp_sockstore addr[];
 };
 
 struct sctp_status {
@@ -1142,12 +1147,6 @@ struct sctpstat {
 #define SCTP_STAT_DECR_COUNTER32(_x) SCTP_STAT_DECR(_x)
 #define SCTP_STAT_DECR_COUNTER64(_x) SCTP_STAT_DECR(_x)
 #define SCTP_STAT_DECR_GAUGE32(_x) SCTP_STAT_DECR(_x)
-
-union sctp_sockstore {
-   struct sockaddr_in sin;
-   struct sockaddr_in6 sin6;
-   struct sockaddr sa;
-};
 
 
 /***/

Modified: head/sys/netinet/sctp_usrreq.c
==
--- head/sys/netinet/sctp_usrreq.c  Sun Jun 21 22:09:30 2020
(r362472)
+++ head/sys/netinet/sctp_usrreq.c  Sun Jun 21 23:12:56 2020
(r362473)
@@ -989,7 +989,7 @@ sctp_shutdown(struct socket *so)
  * returns 0 on success, 1 on error
  */
 static uint32_t
-sctp_fill_user_address(struct sockaddr_storage *ss, struct sockaddr *sa)

svn commit: r362462 - head/sys/netinet

2020-06-21 Thread Michael Tuexen
Author: tuexen
Date: Sun Jun 21 09:56:09 2020
New Revision: 362462
URL: https://svnweb.freebsd.org/changeset/base/362462

Log:
  Fix the build for an INET6 only configuration.
  
  The fix from the last commit is actually needed twice...
  
  MFC after:1 week

Modified:
  head/sys/netinet/sctputil.c

Modified: head/sys/netinet/sctputil.c
==
--- head/sys/netinet/sctputil.c Sun Jun 21 09:24:47 2020(r362461)
+++ head/sys/netinet/sctputil.c Sun Jun 21 09:56:09 2020(r362462)
@@ -6853,6 +6853,8 @@ sctp_bindx_delete_address(struct sctp_inpcb *inp,
} else {
addr_to_use = sa;
}
+#else
+   addr_to_use = sa;
 #endif
break;
 #endif
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r362454 - head/sys/netinet

2020-06-20 Thread Michael Tuexen
Author: tuexen
Date: Sat Jun 20 23:48:57 2020
New Revision: 362454
URL: https://svnweb.freebsd.org/changeset/base/362454

Log:
  Set a variable also in the case of an INET6 only kernel
  
  MFC after:1 week

Modified:
  head/sys/netinet/sctputil.c

Modified: head/sys/netinet/sctputil.c
==
--- head/sys/netinet/sctputil.c Sat Jun 20 21:32:14 2020(r362453)
+++ head/sys/netinet/sctputil.c Sat Jun 20 23:48:57 2020(r362454)
@@ -6746,6 +6746,8 @@ sctp_bindx_add_address(struct socket *so, struct sctp_
} else {
addr_to_use = sa;
}
+#else
+   addr_to_use = sa;
 #endif
break;
 #endif
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r362451 - in head: lib/libc/net sys/netinet

2020-06-20 Thread Michael Tuexen
Author: tuexen
Date: Sat Jun 20 21:06:02 2020
New Revision: 362451
URL: https://svnweb.freebsd.org/changeset/base/362451

Log:
  Use a struct sockaddr_in pr struct sockaddr_in6 as the option value
  for the IPPROTO_SCTP level socket options SCTP_BINDX_ADD_ADDR and
  SCTP_BINDX_REM_ADDR. These socket option are intended for internal
  use only to implement sctp_bindx().
  This is one user of struct sctp_getaddresses less.
  struct sctp_getaddresses is strange and will be changed shortly.

Modified:
  head/lib/libc/net/sctp_sys_calls.c
  head/sys/netinet/sctp_usrreq.c

Modified: head/lib/libc/net/sctp_sys_calls.c
==
--- head/lib/libc/net/sctp_sys_calls.c  Sat Jun 20 20:25:39 2020
(r362450)
+++ head/lib/libc/net/sctp_sys_calls.c  Sat Jun 20 21:06:02 2020
(r362451)
@@ -35,6 +35,7 @@
 #include 
 __FBSDID("$FreeBSD$");
 
+#include 
 #include 
 #include 
 #include 
@@ -170,13 +171,12 @@ sctp_connectx(int sd, const struct sockaddr *addrs, in
 int
 sctp_bindx(int sd, struct sockaddr *addrs, int addrcnt, int flags)
 {
-   struct sctp_getaddresses *gaddrs;
struct sockaddr *sa;
struct sockaddr_in *sin;
struct sockaddr_in6 *sin6;
int i;
-   size_t argsz;
-   uint16_t sport = 0;
+   uint16_t sport;
+   bool fix_port;
 
/* validate the flags */
if ((flags != SCTP_BINDX_ADD_ADDR) &&
@@ -189,6 +189,8 @@ sctp_bindx(int sd, struct sockaddr *addrs, int addrcnt
errno = EINVAL;
return (-1);
}
+   sport = 0;
+   fix_port = false;
/* First pre-screen the addresses */
sa = addrs;
for (i = 0; i < addrcnt; i++) {
@@ -210,6 +212,7 @@ sctp_bindx(int sd, struct sockaddr *addrs, int addrcnt
} else {
/* save off the port */
sport = sin->sin_port;
+   fix_port = (i > 0);
}
}
break;
@@ -230,6 +233,7 @@ sctp_bindx(int sd, struct sockaddr *addrs, int addrcnt
} else {
/* save off the port */
sport = sin6->sin6_port;
+   fix_port = (i > 0);
}
}
break;
@@ -240,42 +244,29 @@ sctp_bindx(int sd, struct sockaddr *addrs, int addrcnt
}
sa = (struct sockaddr *)((caddr_t)sa + sa->sa_len);
}
-   argsz = sizeof(struct sctp_getaddresses) +
-   sizeof(struct sockaddr_storage);
-   if ((gaddrs = (struct sctp_getaddresses *)malloc(argsz)) == NULL) {
-   errno = ENOMEM;
-   return (-1);
-   }
sa = addrs;
for (i = 0; i < addrcnt; i++) {
-   memset(gaddrs, 0, argsz);
-   gaddrs->sget_assoc_id = 0;
-   memcpy(gaddrs->addr, sa, sa->sa_len);
/*
 * Now, if there was a port mentioned, assure that the first
 * address has that port to make sure it fails or succeeds
 * correctly.
 */
-   if ((i == 0) && (sport != 0)) {
-   switch (gaddrs->addr->sa_family) {
+   if (fix_port) {
+   switch (sa->sa_family) {
case AF_INET:
-   sin = (struct sockaddr_in *)gaddrs->addr;
-   sin->sin_port = sport;
+   ((struct sockaddr_in *)sa)->sin_port = sport;
break;
case AF_INET6:
-   sin6 = (struct sockaddr_in6 *)gaddrs->addr;
-   sin6->sin6_port = sport;
+   ((struct sockaddr_in6 *)sa)->sin6_port = sport;
break;
}
+   fix_port = false;
}
-   if (setsockopt(sd, IPPROTO_SCTP, flags, gaddrs,
-   (socklen_t)argsz) != 0) {
-   free(gaddrs);
+   if (setsockopt(sd, IPPROTO_SCTP, flags, sa, sa->sa_len) != 0) {
return (-1);
}
sa = (struct sockaddr *)((caddr_t)sa + sa->sa_len);
}
-   free(gaddrs);
return (0);
 }
 

Modified: head/sys/netinet/sctp_usrreq.c
==
--- head/sys/netinet/sctp_usrreq.c  Sat Jun 20 20:25:39 2020
(r362450)
+++ head/sys/netinet/sctp_usrreq.c  Sat Jun 20 21:06:02 2020
(r362451)
@@ -5995,33 +5995,35 @@ sctp_setopt(struct socket *so, int optname, void *optv
  

svn commit: r362448 - head/sys/netinet

2020-06-20 Thread Michael Tuexen
Author: tuexen
Date: Sat Jun 20 20:20:16 2020
New Revision: 362448
URL: https://svnweb.freebsd.org/changeset/base/362448

Log:
  Cleanup the adding and deleting of addresses via sctp_bindx().
  
  There is no need to use the association identifier, so remove it.
  While there, cleanup the code a bit.
  
  MFC after:1 week

Modified:
  head/sys/netinet/sctp_usrreq.c
  head/sys/netinet/sctputil.c
  head/sys/netinet/sctputil.h

Modified: head/sys/netinet/sctp_usrreq.c
==
--- head/sys/netinet/sctp_usrreq.c  Sat Jun 20 20:14:50 2020
(r362447)
+++ head/sys/netinet/sctp_usrreq.c  Sat Jun 20 20:20:16 2020
(r362448)
@@ -6032,9 +6032,7 @@ sctp_setopt(struct socket *so, int optname, void *optv
error = EAFNOSUPPORT;
break;
}
-   sctp_bindx_add_address(so, inp, addrs->addr,
-   addrs->sget_assoc_id, vrf_id,
-   , p);
+   sctp_bindx_add_address(so, inp, addrs->addr, vrf_id, 
, p);
break;
}
case SCTP_BINDX_REM_ADDR:
@@ -6078,9 +6076,7 @@ sctp_setopt(struct socket *so, int optname, void *optv
error = EAFNOSUPPORT;
break;
}
-   sctp_bindx_delete_address(inp, addrs->addr,
-   addrs->sget_assoc_id, vrf_id,
-   );
+   sctp_bindx_delete_address(inp, addrs->addr, vrf_id, 
);
break;
}
case SCTP_EVENT:

Modified: head/sys/netinet/sctputil.c
==
--- head/sys/netinet/sctputil.c Sat Jun 20 20:14:50 2020(r362447)
+++ head/sys/netinet/sctputil.c Sat Jun 20 20:20:16 2020(r362448)
@@ -6694,13 +6694,21 @@ sctp_connectx_helper_find(struct sctp_inpcb *inp, stru
  */
 void
 sctp_bindx_add_address(struct socket *so, struct sctp_inpcb *inp,
-struct sockaddr *sa, sctp_assoc_t assoc_id,
-uint32_t vrf_id, int *error, void *p)
+struct sockaddr *sa, uint32_t vrf_id, int *error,
+void *p)
 {
-   struct sockaddr *addr_touse;
 #if defined(INET) && defined(INET6)
struct sockaddr_in sin;
 #endif
+#ifdef INET6
+   struct sockaddr_in6 *sin6;
+#endif
+#ifdef INET
+   struct sockaddr_in *sinp;
+#endif
+   struct sockaddr *addr_to_use;
+   struct sctp_inpcb *lep;
+   uint16_t port;
 
/* see if we're bound all already! */
if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) {
@@ -6708,13 +6716,9 @@ sctp_bindx_add_address(struct socket *so, struct sctp_
*error = EINVAL;
return;
}
-   addr_touse = sa;
+   switch (sa->sa_family) {
 #ifdef INET6
-   if (sa->sa_family == AF_INET6) {
-#ifdef INET
-   struct sockaddr_in6 *sin6;
-
-#endif
+   case AF_INET6:
if (sa->sa_len != sizeof(struct sockaddr_in6)) {
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, 
SCTP_FROM_SCTPUTIL, EINVAL);
*error = EINVAL;
@@ -6726,8 +6730,9 @@ sctp_bindx_add_address(struct socket *so, struct sctp_
*error = EINVAL;
return;
}
+   sin6 = (struct sockaddr_in6 *)sa;
+   port = sin6->sin6_port;
 #ifdef INET
-   sin6 = (struct sockaddr_in6 *)addr_touse;
if (IN6_IS_ADDR_V4MAPPED(>sin6_addr)) {
if ((inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) &&
SCTP_IPV6_V6ONLY(inp)) {
@@ -6737,13 +6742,15 @@ sctp_bindx_add_address(struct socket *so, struct sctp_
return;
}
in6_sin6_2_sin(, sin6);
-   addr_touse = (struct sockaddr *)
+   addr_to_use = (struct sockaddr *)
+   } else {
+   addr_to_use = sa;
}
 #endif
-   }
+   break;
 #endif
 #ifdef INET
-   if (sa->sa_family == AF_INET) {
+   case AF_INET:
if (sa->sa_len != sizeof(struct sockaddr_in)) {
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, 
SCTP_FROM_SCTPUTIL, EINVAL);
*error = EINVAL;
@@ -6756,8 +6763,16 @@ sctp_bindx_add_address(struct socket *so, struct sctp_
*error = EINVAL;
return;
}
-   }
+   sinp = (struct sockaddr_in *)sa;
+   port = sinp->sin_port;
+   addr_to_use = sa;
+   break;
 #endif
+   default:
+   SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTPUTIL, 
EINVAL);
+   *error = 

svn commit: r362377 - head/sys/netinet

2020-06-19 Thread Michael Tuexen
Author: tuexen
Date: Fri Jun 19 12:35:29 2020
New Revision: 362377
URL: https://svnweb.freebsd.org/changeset/base/362377

Log:
  Remove last argument of sctp_addr_mgmt_ep_sa(), since it is not used.
  
  MFC after:1 week

Modified:
  head/sys/netinet/sctp_asconf.c
  head/sys/netinet/sctp_asconf.h
  head/sys/netinet/sctputil.c

Modified: head/sys/netinet/sctp_asconf.c
==
--- head/sys/netinet/sctp_asconf.c  Fri Jun 19 11:47:40 2020
(r362376)
+++ head/sys/netinet/sctp_asconf.c  Fri Jun 19 12:35:29 2020
(r362377)
@@ -3165,7 +3165,7 @@ sctp_check_address_list(struct sctp_tcb *stcb, struct 
  */
 uint32_t
 sctp_addr_mgmt_ep_sa(struct sctp_inpcb *inp, struct sockaddr *sa,
-uint32_t type, uint32_t vrf_id, struct sctp_ifa *sctp_ifap)
+uint32_t type, uint32_t vrf_id)
 {
struct sctp_ifa *ifa;
struct sctp_laddr *laddr, *nladdr;
@@ -3174,9 +3174,7 @@ sctp_addr_mgmt_ep_sa(struct sctp_inpcb *inp, struct so
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_ASCONF, 
EINVAL);
return (EINVAL);
}
-   if (sctp_ifap) {
-   ifa = sctp_ifap;
-   } else if (type == SCTP_ADD_IP_ADDRESS) {
+   if (type == SCTP_ADD_IP_ADDRESS) {
/* For an add the address MUST be on the system */
ifa = sctp_find_ifa_by_addr(sa, vrf_id, SCTP_ADDR_NOT_LOCKED);
} else if (type == SCTP_DEL_IP_ADDRESS) {

Modified: head/sys/netinet/sctp_asconf.h
==
--- head/sys/netinet/sctp_asconf.h  Fri Jun 19 11:47:40 2020
(r362376)
+++ head/sys/netinet/sctp_asconf.h  Fri Jun 19 12:35:29 2020
(r362377)
@@ -56,8 +56,8 @@ sctp_handle_asconf_ack(struct mbuf *, int, struct sctp
 struct sctp_tcb *, struct sctp_nets *, int *);
 
 extern uint32_t
-sctp_addr_mgmt_ep_sa(struct sctp_inpcb *, struct sockaddr *,
-uint32_t, uint32_t, struct sctp_ifa *);
+sctp_addr_mgmt_ep_sa(struct sctp_inpcb *, struct sockaddr *, uint32_t,
+uint32_t);
 
 
 extern int

Modified: head/sys/netinet/sctputil.c
==
--- head/sys/netinet/sctputil.c Fri Jun 19 11:47:40 2020(r362376)
+++ head/sys/netinet/sctputil.c Fri Jun 19 12:35:29 2020(r362377)
@@ -6804,8 +6804,7 @@ sctp_bindx_add_address(struct socket *so, struct sctp_
} else if (lep == NULL) {
((struct sockaddr_in *)addr_touse)->sin_port = 0;
*error = sctp_addr_mgmt_ep_sa(inp, addr_touse,
-   SCTP_ADD_IP_ADDRESS,
-   vrf_id, NULL);
+   SCTP_ADD_IP_ADDRESS, vrf_id);
} else {
*error = EADDRINUSE;
}
@@ -6896,8 +6895,7 @@ sctp_bindx_delete_address(struct sctp_inpcb *inp,
if (assoc_id == 0) {
/* delete the address */
*error = sctp_addr_mgmt_ep_sa(inp, addr_touse,
-   SCTP_DEL_IP_ADDRESS,
-   vrf_id, NULL);
+   SCTP_DEL_IP_ADDRESS, vrf_id);
} else {
/*
 * FIX: decide whether we allow assoc based bindx
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r362332 - head/lib/libc/net

2020-06-18 Thread Michael Tuexen
Author: tuexen
Date: Thu Jun 18 16:22:09 2020
New Revision: 362332
URL: https://svnweb.freebsd.org/changeset/base/362332

Log:
  Whitespace changes, not functional change intended.
  
  MFC after:1 week

Modified:
  head/lib/libc/net/sctp_sys_calls.c

Modified: head/lib/libc/net/sctp_sys_calls.c
==
--- head/lib/libc/net/sctp_sys_calls.c  Thu Jun 18 15:44:40 2020
(r362331)
+++ head/lib/libc/net/sctp_sys_calls.c  Thu Jun 18 16:22:09 2020
(r362332)
@@ -100,7 +100,7 @@ sctp_getaddrlen(sa_family_t family)
 
 int
 sctp_connectx(int sd, const struct sockaddr *addrs, int addrcnt,
-sctp_assoc_t * id)
+sctp_assoc_t *id)
 {
char *buf;
int i, ret, *aa;
@@ -159,9 +159,9 @@ sctp_connectx(int sd, const struct sockaddr *addrs, in
aa = (int *)buf;
*aa = addrcnt;
ret = setsockopt(sd, IPPROTO_SCTP, SCTP_CONNECT_X, (void *)buf,
-   (socklen_t) len);
+   (socklen_t)len);
if ((ret == 0) && (id != NULL)) {
-   *id = *(sctp_assoc_t *) buf;
+   *id = *(sctp_assoc_t *)buf;
}
free(buf);
return (ret);
@@ -269,7 +269,7 @@ sctp_bindx(int sd, struct sockaddr *addrs, int addrcnt
}
}
if (setsockopt(sd, IPPROTO_SCTP, flags, gaddrs,
-   (socklen_t) argsz) != 0) {
+   (socklen_t)argsz) != 0) {
free(gaddrs);
return (-1);
}
@@ -280,7 +280,7 @@ sctp_bindx(int sd, struct sockaddr *addrs, int addrcnt
 }
 
 int
-sctp_opt_info(int sd, sctp_assoc_t id, int opt, void *arg, socklen_t * size)
+sctp_opt_info(int sd, sctp_assoc_t id, int opt, void *arg, socklen_t *size)
 {
if (arg == NULL) {
errno = EINVAL;
@@ -409,13 +409,13 @@ sctp_getpaddrs(int sd, sctp_assoc_t id, struct sockadd
return (-1);
}
asoc = id;
-   opt_len = (socklen_t) sizeof(sctp_assoc_t);
+   opt_len = (socklen_t)sizeof(sctp_assoc_t);
if (getsockopt(sd, IPPROTO_SCTP, SCTP_GET_REMOTE_ADDR_SIZE,
, _len) != 0) {
return (-1);
}
/* size required is returned in 'asoc' */
-   opt_len = (socklen_t) ((size_t)asoc + sizeof(sctp_assoc_t));
+   opt_len = (socklen_t)((size_t)asoc + sizeof(sctp_assoc_t));
addrs = calloc(1, (size_t)opt_len);
if (addrs == NULL) {
errno = ENOMEM;
@@ -465,7 +465,7 @@ sctp_getladdrs(int sd, sctp_assoc_t id, struct sockadd
return (-1);
}
size_of_addresses = 0;
-   opt_len = (socklen_t) sizeof(int);
+   opt_len = (socklen_t)sizeof(int);
if (getsockopt(sd, IPPROTO_SCTP, SCTP_GET_LOCAL_ADDR_SIZE,
_of_addresses, _len) != 0) {
errno = ENOMEM;
@@ -475,7 +475,7 @@ sctp_getladdrs(int sd, sctp_assoc_t id, struct sockadd
errno = ENOTCONN;
return (-1);
}
-   opt_len = (socklen_t) (size_of_addresses + sizeof(sctp_assoc_t));
+   opt_len = (socklen_t)(size_of_addresses + sizeof(sctp_assoc_t));
addrs = calloc(1, (size_t)opt_len);
if (addrs == NULL) {
errno = ENOMEM;
@@ -586,6 +586,7 @@ sctp_sendmsg(int s,
}
who = (struct sockaddr *)
}
+
iov.iov_base = (char *)data;
iov.iov_len = len;
 
@@ -632,7 +633,7 @@ sctp_getassocid(int sd, struct sockaddr *sa)
if (getsockopt(sd, IPPROTO_SCTP,
SCTP_GET_PEER_ADDR_INFO, , ) != 0) {
/* We depend on the fact that 0 can never be returned */
-   return ((sctp_assoc_t) 0);
+   return ((sctp_assoc_t)0);
}
return (sp.spinfo_assoc_id);
 }
@@ -748,7 +749,7 @@ sctp_sendx(int sd, const void *msg, size_t msg_len,
aa++;
memcpy((caddr_t)aa, addrs, (size_t)(len - sizeof(int)));
ret = setsockopt(sd, IPPROTO_SCTP, SCTP_CONNECT_X_DELAYED, (void *)buf,
-   (socklen_t) len);
+   (socklen_t)len);
 
free(buf);
if (ret != 0) {
@@ -766,7 +767,7 @@ continue_send:
sinfo->sinfo_assoc_id = sctp_getassocid(sd, addrs);
if (sinfo->sinfo_assoc_id == 0) {
(void)setsockopt(sd, IPPROTO_SCTP, SCTP_CONNECT_X_COMPLETE, 
(void *)addrs,
-   (socklen_t) addrs->sa_len);
+   (socklen_t)addrs->sa_len);
errno = ENOENT;
return (-1);
}
@@ -774,7 +775,7 @@ continue_send:
saved_errno = errno;
if (no_end_cx == 0)
(void)setsockopt(sd, IPPROTO_SCTP, SCTP_CONNECT_X_COMPLETE, 
(void *)addrs,
-   (socklen_t) addrs->sa_len);
+   (socklen_t)addrs->sa_len);
 
errno = saved_errno;
return (ret);
@@ -808,7 +809,7 @@ sctp_recvmsg(int s,
 void *dbuf,
 size_t len,
   

svn commit: r362277 - head/sys/netinet

2020-06-17 Thread Michael Tuexen
Author: tuexen
Date: Wed Jun 17 15:27:45 2020
New Revision: 362277
URL: https://svnweb.freebsd.org/changeset/base/362277

Log:
  Allow the self reference to be NULL in case the timer was stopped.
  
  Submitted by: Timo Voelker
  MFC after:1 week

Modified:
  head/sys/netinet/sctputil.c

Modified: head/sys/netinet/sctputil.c
==
--- head/sys/netinet/sctputil.c Wed Jun 17 13:46:05 2020(r362276)
+++ head/sys/netinet/sctputil.c Wed Jun 17 15:27:45 2020(r362277)
@@ -1730,7 +1730,7 @@ sctp_timeout_handler(void *t)
 #endif
 
/* sanity checks... */
-   KASSERT(tmr->self == tmr,
+   KASSERT(tmr->self == NULL || tmr->self == tmr,
("sctp_timeout_handler: tmr->self corrupted"));
KASSERT(SCTP_IS_TIMER_TYPE_VALID(tmr->type),
("sctp_timeout_handler: invalid timer type %d", tmr->type));
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r362178 - head/sys/netinet

2020-06-14 Thread Michael Tuexen
Author: tuexen
Date: Sun Jun 14 16:05:08 2020
New Revision: 362178
URL: https://svnweb.freebsd.org/changeset/base/362178

Log:
  Allocate the mbuf for the signature in the COOKIE or the correct size.
  While there, do also do some cleanups.
  
  MFC after:1 week

Modified:
  head/sys/netinet/sctp_output.c

Modified: head/sys/netinet/sctp_output.c
==
--- head/sys/netinet/sctp_output.c  Sun Jun 14 15:49:32 2020
(r362177)
+++ head/sys/netinet/sctp_output.c  Sun Jun 14 16:05:08 2020
(r362178)
@@ -3831,8 +3831,6 @@ sctp_add_cookie(struct mbuf *init, int init_offset,
struct mbuf *copy_init, *copy_initack, *m_at, *sig, *mret;
struct sctp_state_cookie *stc;
struct sctp_paramhdr *ph;
-   uint8_t *foo;
-   int sig_offset;
uint16_t cookie_sz;
 
mret = sctp_get_mbuf_for_msg((sizeof(struct sctp_state_cookie) +
@@ -3896,24 +3894,20 @@ sctp_add_cookie(struct mbuf *init, int init_offset,
break;
}
}
-   sig = sctp_get_mbuf_for_msg(SCTP_SECRET_SIZE, 0, M_NOWAIT, 1, MT_DATA);
+   sig = sctp_get_mbuf_for_msg(SCTP_SIGNATURE_SIZE, 0, M_NOWAIT, 1, 
MT_DATA);
if (sig == NULL) {
/* no space, so free the entire chain */
sctp_m_freem(mret);
return (NULL);
}
-   SCTP_BUF_LEN(sig) = 0;
SCTP_BUF_NEXT(m_at) = sig;
-   sig_offset = 0;
-   foo = (uint8_t *)(mtod(sig, caddr_t)+sig_offset);
-   memset(foo, 0, SCTP_SIGNATURE_SIZE);
-   *signature = foo;
-   SCTP_BUF_LEN(sig) += SCTP_SIGNATURE_SIZE;
+   SCTP_BUF_LEN(sig) = SCTP_SIGNATURE_SIZE;
cookie_sz += SCTP_SIGNATURE_SIZE;
ph->param_length = htons(cookie_sz);
+   *signature = (uint8_t *)mtod(sig, caddr_t);
+   memset(*signature, 0, SCTP_SIGNATURE_SIZE);
return (mret);
 }
-
 
 static uint8_t
 sctp_get_ect(struct sctp_tcb *stcb)
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r362173 - head/sys/netinet

2020-06-14 Thread Michael Tuexen
Author: tuexen
Date: Sun Jun 14 09:50:00 2020
New Revision: 362173
URL: https://svnweb.freebsd.org/changeset/base/362173

Log:
  Cleanups, no functional change.
  
  MFC after:1 week

Modified:
  head/sys/netinet/sctp_indata.c
  head/sys/netinet/sctp_output.c
  head/sys/netinet/sctp_ss_functions.c
  head/sys/netinet/sctputil.c

Modified: head/sys/netinet/sctp_indata.c
==
--- head/sys/netinet/sctp_indata.c  Sun Jun 14 06:58:58 2020
(r362172)
+++ head/sys/netinet/sctp_indata.c  Sun Jun 14 09:50:00 2020
(r362173)
@@ -66,7 +66,7 @@ sctp_add_chk_to_control(struct sctp_queued_to_read *co
 struct sctp_stream_in *strm,
 struct sctp_tcb *stcb,
 struct sctp_association *asoc,
-struct sctp_tmit_chunk *chk, int lock_held);
+struct sctp_tmit_chunk *chk, int hold_rlock);
 
 
 void

Modified: head/sys/netinet/sctp_output.c
==
--- head/sys/netinet/sctp_output.c  Sun Jun 14 06:58:58 2020
(r362172)
+++ head/sys/netinet/sctp_output.c  Sun Jun 14 09:50:00 2020
(r362173)
@@ -5118,7 +5118,6 @@ sctp_arethere_unrecognized_parameters(struct mbuf *in_
}
}
return (op_err);
-   break;
}
default:
/*

Modified: head/sys/netinet/sctp_ss_functions.c
==
--- head/sys/netinet/sctp_ss_functions.cSun Jun 14 06:58:58 2020
(r362172)
+++ head/sys/netinet/sctp_ss_functions.cSun Jun 14 09:50:00 2020
(r362173)
@@ -767,8 +767,8 @@ sctp_ss_fb_scheduled(struct sctp_tcb *stcb, struct sct
  */
 static void
 sctp_ss_fcfs_add(struct sctp_tcb *stcb, struct sctp_association *asoc,
-struct sctp_stream_out *strq, struct sctp_stream_queue_pending *sp,
-int holds_lock);
+struct sctp_stream_out *strq SCTP_UNUSED,
+struct sctp_stream_queue_pending *sp, int holds_lock);
 
 static void
 sctp_ss_fcfs_init(struct sctp_tcb *stcb, struct sctp_association *asoc,

Modified: head/sys/netinet/sctputil.c
==
--- head/sys/netinet/sctputil.c Sun Jun 14 06:58:58 2020(r362172)
+++ head/sys/netinet/sctputil.c Sun Jun 14 09:50:00 2020(r362173)
@@ -5230,10 +5230,6 @@ sctp_find_ifa_in_ep(struct sctp_inpcb *inp, struct soc
if (((struct sockaddr_in *)addr)->sin_addr.s_addr ==
laddr->ifa->address.sin.sin_addr.s_addr) {
/* found him. */
-   if (holds_lock == 0) {
-   SCTP_INP_RUNLOCK(inp);
-   }
-   return (laddr->ifa);
break;
}
}
@@ -5243,10 +5239,6 @@ sctp_find_ifa_in_ep(struct sctp_inpcb *inp, struct soc
if (SCTP6_ARE_ADDR_EQUAL((struct sockaddr_in6 *)addr,
>ifa->address.sin6)) {
/* found him. */
-   if (holds_lock == 0) {
-   SCTP_INP_RUNLOCK(inp);
-   }
-   return (laddr->ifa);
break;
}
}
@@ -5255,7 +5247,7 @@ sctp_find_ifa_in_ep(struct sctp_inpcb *inp, struct soc
if (holds_lock == 0) {
SCTP_INP_RUNLOCK(inp);
}
-   return (NULL);
+   return (laddr->ifa);
 }
 
 uint32_t
@@ -5332,9 +5324,6 @@ sctp_find_ifa_by_addr(struct sockaddr *addr, uint32_t 
if (((struct sockaddr_in *)addr)->sin_addr.s_addr ==
sctp_ifap->address.sin.sin_addr.s_addr) {
/* found him. */
-   if (holds_lock == 0)
-   SCTP_IPI_ADDR_RUNLOCK();
-   return (sctp_ifap);
break;
}
}
@@ -5344,9 +5333,6 @@ sctp_find_ifa_by_addr(struct sockaddr *addr, uint32_t 
if (SCTP6_ARE_ADDR_EQUAL((struct sockaddr_in6 *)addr,
_ifap->address.sin6)) {
/* found him. */
-   if (holds_lock == 0)
-   SCTP_IPI_ADDR_RUNLOCK();
-   return (sctp_ifap);
break;
}
}
@@ -5354,7 +5340,7 @@ sctp_find_ifa_by_addr(struct sockaddr *addr, uint32_t 
}

svn commit: r362155 - head/sys/netinet

2020-06-13 Thread Michael Tuexen
Author: tuexen
Date: Sat Jun 13 21:23:26 2020
New Revision: 362155
URL: https://svnweb.freebsd.org/changeset/base/362155

Log:
  Remove usage of empty macro.
  
  MFC after:1 week

Modified:
  head/sys/netinet/sctp_os_bsd.h
  head/sys/netinet/sctp_pcb.c

Modified: head/sys/netinet/sctp_os_bsd.h
==
--- head/sys/netinet/sctp_os_bsd.h  Sat Jun 13 20:54:18 2020
(r362154)
+++ head/sys/netinet/sctp_os_bsd.h  Sat Jun 13 21:23:26 2020
(r362155)
@@ -312,11 +312,6 @@ typedef struct callout sctp_os_timer_t;
 #define SCTP_GATHER_MTU_FROM_ROUTE(sctp_ifa, sa, nh) ((uint32_t)((nh != NULL) 
? nh->nh_mtu : 0))
 #define SCTP_GATHER_MTU_FROM_INTFC(sctp_ifn) ((sctp_ifn->ifn_p != NULL) ? 
((struct ifnet *)(sctp_ifn->ifn_p))->if_mtu : 0)
 
-/* (de-)register interface event notifications */
-#define SCTP_REGISTER_INTERFACE(ifhandle, af)
-#define SCTP_DEREGISTER_INTERFACE(ifhandle, af)
-
-
 /*/
 /* These are for logging */
 /*/

Modified: head/sys/netinet/sctp_pcb.c
==
--- head/sys/netinet/sctp_pcb.c Sat Jun 13 20:54:18 2020(r362154)
+++ head/sys/netinet/sctp_pcb.c Sat Jun 13 21:23:26 2020(r362155)
@@ -301,8 +301,6 @@ sctp_delete_ifn(struct sctp_ifn *sctp_ifnp, int hold_a
SCTP_IPI_ADDR_WLOCK();
LIST_REMOVE(sctp_ifnp, next_bucket);
LIST_REMOVE(sctp_ifnp, next_ifn);
-   SCTP_DEREGISTER_INTERFACE(sctp_ifnp->ifn_index,
-   sctp_ifnp->registered_af);
if (hold_addr_lock == 0)
SCTP_IPI_ADDR_WUNLOCK();
/* Take away the reference, and possibly free it */
@@ -430,7 +428,6 @@ sctp_add_ifa_to_ifn(struct sctp_ifn *sctp_ifnp, struct
}
if (sctp_ifnp->ifa_count == 1) {
/* register the new interface */
-   SCTP_REGISTER_INTERFACE(sctp_ifnp->ifn_index, ifa_af);
sctp_ifnp->registered_af = ifa_af;
}
 }
@@ -471,13 +468,9 @@ sctp_remove_ifa_from_ifn(struct sctp_ifa *sctp_ifap)
/* re-register address family type, if needed */
if ((sctp_ifap->ifn_p->num_v6 == 0) &&
(sctp_ifap->ifn_p->registered_af == AF_INET6)) {
-   
SCTP_DEREGISTER_INTERFACE(sctp_ifap->ifn_p->ifn_index, AF_INET6);
-   
SCTP_REGISTER_INTERFACE(sctp_ifap->ifn_p->ifn_index, AF_INET);
sctp_ifap->ifn_p->registered_af = AF_INET;
} else if ((sctp_ifap->ifn_p->num_v4 == 0) &&
(sctp_ifap->ifn_p->registered_af == AF_INET)) {
-   
SCTP_DEREGISTER_INTERFACE(sctp_ifap->ifn_p->ifn_index, AF_INET);
-   
SCTP_REGISTER_INTERFACE(sctp_ifap->ifn_p->ifn_index, AF_INET6);
sctp_ifap->ifn_p->registered_af = AF_INET6;
}
/* free the ifn refcount */
@@ -678,7 +671,6 @@ sctp_add_addr_to_vrf(uint32_t vrf_id, void *ifn, uint3
vrf->total_ifa_count++;
atomic_add_int(_BASE_INFO(ipi_count_ifas), 1);
if (new_ifn_af) {
-   SCTP_REGISTER_INTERFACE(ifn_index, new_ifn_af);
sctp_ifnp->registered_af = new_ifn_af;
}
SCTP_IPI_ADDR_WUNLOCK();
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r362153 - head/sys/netinet

2020-06-13 Thread Michael Tuexen
Author: tuexen
Date: Sat Jun 13 18:38:59 2020
New Revision: 362153
URL: https://svnweb.freebsd.org/changeset/base/362153

Log:
  Simpify a condition, no functional change.
  
  MFC after:1 week

Modified:
  head/sys/netinet/sctp_input.c

Modified: head/sys/netinet/sctp_input.c
==
--- head/sys/netinet/sctp_input.c   Sat Jun 13 18:21:31 2020
(r362152)
+++ head/sys/netinet/sctp_input.c   Sat Jun 13 18:38:59 2020
(r362153)
@@ -5594,9 +5594,8 @@ trigger_send:
if (!TAILQ_EMPTY(>asoc.asconf_send_queue) ||
cnt_ctrl_ready ||
stcb->asoc.trigger_reset ||
-   ((un_sent) &&
-   (stcb->asoc.peers_rwnd > 0 ||
-   (stcb->asoc.peers_rwnd <= 0 && stcb->asoc.total_flight == 0 {
+   ((un_sent > 0) &&
+   (stcb->asoc.peers_rwnd > 0 || stcb->asoc.total_flight == 0))) {
SCTPDBG(SCTP_DEBUG_INPUT3, "Calling chunk OUTPUT\n");
sctp_chunk_output(inp, stcb, SCTP_OUTPUT_FROM_CONTROL_PROC, 
SCTP_SO_NOT_LOCKED);
SCTPDBG(SCTP_DEBUG_INPUT3, "chunk OUTPUT returns\n");
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r362107 - head/sys/netinet

2020-06-12 Thread Michael Tuexen
Author: tuexen
Date: Fri Jun 12 16:40:10 2020
New Revision: 362107
URL: https://svnweb.freebsd.org/changeset/base/362107

Log:
  Whitespace change due to upstream cleanup.
  
  MFC after:1 week

Modified:
  head/sys/netinet/sctp_constants.h

Modified: head/sys/netinet/sctp_constants.h
==
--- head/sys/netinet/sctp_constants.h   Fri Jun 12 16:31:13 2020
(r362106)
+++ head/sys/netinet/sctp_constants.h   Fri Jun 12 16:40:10 2020
(r362107)
@@ -992,7 +992,7 @@ do { \
 #define sctp_sowwakeup_locked(inp, so) \
 do { \
if (inp->sctp_flags & SCTP_PCB_FLAGS_DONT_WAKE) { \
-SOCKBUF_UNLOCK(&((so)->so_snd)); \
+   SOCKBUF_UNLOCK(&((so)->so_snd)); \
inp->sctp_flags |= SCTP_PCB_FLAGS_WAKEOUTPUT; \
} else { \
sowwakeup_locked(so); \
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r362106 - head/sys/netinet

2020-06-12 Thread Michael Tuexen
Author: tuexen
Date: Fri Jun 12 16:31:13 2020
New Revision: 362106
URL: https://svnweb.freebsd.org/changeset/base/362106

Log:
  More cleanups due to ifdef cleanup done upstream
  
  MFC after:1 week

Modified:
  head/sys/netinet/sctp_constants.h
  head/sys/netinet/sctp_input.c
  head/sys/netinet/sctp_pcb.c
  head/sys/netinet/sctp_pcb.h
  head/sys/netinet/sctp_structs.h
  head/sys/netinet/sctp_uio.h

Modified: head/sys/netinet/sctp_constants.h
==
--- head/sys/netinet/sctp_constants.h   Fri Jun 12 15:37:55 2020
(r362105)
+++ head/sys/netinet/sctp_constants.h   Fri Jun 12 16:31:13 2020
(r362106)
@@ -1012,7 +1012,7 @@ do { \
 do { \
if (inp->sctp_flags & SCTP_PCB_FLAGS_DONT_WAKE) { \
inp->sctp_flags |= SCTP_PCB_FLAGS_WAKEINPUT; \
-SOCKBUF_UNLOCK(&((so)->so_rcv)); \
+   SOCKBUF_UNLOCK(&((so)->so_rcv)); \
} else { \
sorwakeup_locked(so); \
} \

Modified: head/sys/netinet/sctp_input.c
==
--- head/sys/netinet/sctp_input.c   Fri Jun 12 15:37:55 2020
(r362105)
+++ head/sys/netinet/sctp_input.c   Fri Jun 12 16:31:13 2020
(r362106)
@@ -5723,7 +5723,7 @@ out:
return;
 }
 
-#if defined(__FreeBSD__) && defined(SCTP_MCORE_INPUT) && defined(SMP)
+#if defined(SCTP_MCORE_INPUT) && defined(SMP)
 extern int *sctp_cpuarry;
 #endif
 
@@ -5735,7 +5735,7 @@ sctp_input(struct mbuf **mp, int *offp, int proto SCTP
 
m = *mp;
off = *offp;
-#if defined(__FreeBSD__) && defined(SCTP_MCORE_INPUT) && defined(SMP)
+#if defined(SCTP_MCORE_INPUT) && defined(SMP)
if (mp_ncpus > 1) {
struct ip *ip;
struct sctphdr *sh;

Modified: head/sys/netinet/sctp_pcb.c
==
--- head/sys/netinet/sctp_pcb.c Fri Jun 12 15:37:55 2020(r362105)
+++ head/sys/netinet/sctp_pcb.c Fri Jun 12 16:31:13 2020(r362106)
@@ -5535,18 +5535,14 @@ sctp_del_local_addr_restricted(struct sctp_tcb *stcb, 
return;
 }
 
-/*
- * Temporarily remove for __APPLE__ until we use the Tiger equivalents
- */
 /* sysctl */
 static int sctp_max_number_of_assoc = SCTP_MAX_NUM_OF_ASOC;
 static int sctp_scale_up_for_address = SCTP_SCALE_FOR_ADDR;
 
-
-
-#if defined(__FreeBSD__) && defined(SCTP_MCORE_INPUT) && defined(SMP)
+#if defined(SCTP_MCORE_INPUT) && defined(SMP)
 struct sctp_mcore_ctrl *sctp_mcore_workers = NULL;
 int *sctp_cpuarry = NULL;
+
 void
 sctp_queue_to_mcore(struct mbuf *m, int off, int cpu_to_use)
 {
@@ -5716,13 +5712,13 @@ sctp_pcb_init(void)
 #if defined(SCTP_LOCAL_TRACE_BUF)
memset(_BASE_SYSCTL(sctp_log), 0, sizeof(struct sctp_log));
 #endif
-#if defined(__FreeBSD__) && defined(SMP) && defined(SCTP_USE_PERCPU_STAT)
+#if defined(SMP) && defined(SCTP_USE_PERCPU_STAT)
SCTP_MALLOC(SCTP_BASE_STATS, struct sctpstat *,
((mp_maxid + 1) * sizeof(struct sctpstat)),
SCTP_M_MCORE);
 #endif
(void)SCTP_GETTIME_TIMEVAL();
-#if defined(__FreeBSD__) && defined(SMP) && defined(SCTP_USE_PERCPU_STAT)
+#if defined(SMP) && defined(SCTP_USE_PERCPU_STAT)
memset(SCTP_BASE_STATS, 0, sizeof(struct sctpstat) * (mp_maxid + 1));
SCTP_BASE_STATS[PCPU_GET(cpuid)].sctps_discontinuitytime.tv_sec = 
(uint32_t)tv.tv_sec;
SCTP_BASE_STATS[PCPU_GET(cpuid)].sctps_discontinuitytime.tv_usec = 
(uint32_t)tv.tv_usec;
@@ -5833,7 +5829,7 @@ sctp_pcb_init(void)
}
sctp_startup_iterator();
 
-#if defined(__FreeBSD__) && defined(SCTP_MCORE_INPUT) && defined(SMP)
+#if defined(SCTP_MCORE_INPUT) && defined(SMP)
sctp_startup_mcore_threads();
 #endif
 
@@ -5988,7 +5984,7 @@ retry:
SCTP_ZONE_DESTROY(SCTP_BASE_INFO(ipi_zone_strmoq));
SCTP_ZONE_DESTROY(SCTP_BASE_INFO(ipi_zone_asconf));
SCTP_ZONE_DESTROY(SCTP_BASE_INFO(ipi_zone_asconf_ack));
-#if defined(__FreeBSD__) && defined(SMP) && defined(SCTP_USE_PERCPU_STAT)
+#if defined(SMP) && defined(SCTP_USE_PERCPU_STAT)
SCTP_FREE(SCTP_BASE_STATS, SCTP_M_MCORE);
 #endif
 }

Modified: head/sys/netinet/sctp_pcb.h
==
--- head/sys/netinet/sctp_pcb.h Fri Jun 12 15:37:55 2020(r362105)
+++ head/sys/netinet/sctp_pcb.h Fri Jun 12 16:31:13 2020(r362106)
@@ -246,7 +246,7 @@ struct sctp_base_info {
 * All static structures that anchor the system must be here.
 */
struct sctp_epinfo sctppcbinfo;
-#if defined(__FreeBSD__) && defined(SMP) && defined(SCTP_USE_PERCPU_STAT)
+#if defined(SMP) && defined(SCTP_USE_PERCPU_STAT)
struct sctpstat *sctpstat;
 #else
struct sctpstat sctpstat;
@@ -478,7 +478,6 @@ struct sctp_tcb {
 #include 
 
 
-/* TODO where to put non-_KERNEL things for __Userspace__? */
 #if 

svn commit: r362090 - head/sys/netinet

2020-06-12 Thread Michael Tuexen
Author: tuexen
Date: Fri Jun 12 10:13:23 2020
New Revision: 362090
URL: https://svnweb.freebsd.org/changeset/base/362090

Log:
  Small cleanup due to upstream ifdef cleanups.
  
  MFC after:1 week

Modified:
  head/sys/netinet/sctputil.h

Modified: head/sys/netinet/sctputil.h
==
--- head/sys/netinet/sctputil.h Fri Jun 12 09:34:10 2020(r362089)
+++ head/sys/netinet/sctputil.h Fri Jun 12 10:13:23 2020(r362090)
@@ -55,7 +55,7 @@ void sctp_m_freem(struct mbuf *m);
 #define sctp_m_freem m_freem
 #endif
 
-#if defined(SCTP_LOCAL_TRACE_BUF) || defined(__APPLE__)
+#if defined(SCTP_LOCAL_TRACE_BUF)
 void
  sctp_log_trace(uint32_t fr, const char *str SCTP_UNUSED, uint32_t a, 
uint32_t b, uint32_t c, uint32_t d, uint32_t e, uint32_t f);
 #endif
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r362054 - head/sys/netinet

2020-06-11 Thread Michael Tuexen
Author: tuexen
Date: Thu Jun 11 13:34:09 2020
New Revision: 362054
URL: https://svnweb.freebsd.org/changeset/base/362054

Log:
  Non-functional changes due to upstream cleanup.
  
  MFC after:1 week

Modified:
  head/sys/netinet/sctp_asconf.c
  head/sys/netinet/sctp_auth.c
  head/sys/netinet/sctp_input.c
  head/sys/netinet/sctp_output.c
  head/sys/netinet/sctp_output.h
  head/sys/netinet/sctp_pcb.c
  head/sys/netinet/sctp_peeloff.c
  head/sys/netinet/sctp_timer.c
  head/sys/netinet/sctp_usrreq.c
  head/sys/netinet/sctputil.c
  head/sys/netinet/sctputil.h

Modified: head/sys/netinet/sctp_asconf.c
==
--- head/sys/netinet/sctp_asconf.c  Thu Jun 11 12:53:22 2020
(r362053)
+++ head/sys/netinet/sctp_asconf.c  Thu Jun 11 13:34:09 2020
(r362054)
@@ -51,7 +51,6 @@ __FBSDID("$FreeBSD$");
  * SCTP_DEBUG_ASCONF2: detailed info
  */
 
-
 /*
  * RFC 5061
  *

Modified: head/sys/netinet/sctp_auth.c
==
--- head/sys/netinet/sctp_auth.cThu Jun 11 12:53:22 2020
(r362053)
+++ head/sys/netinet/sctp_auth.cThu Jun 11 13:34:09 2020
(r362054)
@@ -565,9 +565,7 @@ sctp_auth_key_acquire(struct sctp_tcb *stcb, uint16_t 
 }
 
 void
-sctp_auth_key_release(struct sctp_tcb *stcb, uint16_t key_id, int so_locked
-SCTP_UNUSED
-)
+sctp_auth_key_release(struct sctp_tcb *stcb, uint16_t key_id, int so_locked)
 {
sctp_sharedkey_t *skey;
 
@@ -1718,9 +1716,7 @@ sctp_handle_auth(struct sctp_tcb *stcb, struct sctp_au
  */
 void
 sctp_notify_authentication(struct sctp_tcb *stcb, uint32_t indication,
-uint16_t keyid, uint16_t alt_keyid, int so_locked
-SCTP_UNUSED
-)
+uint16_t keyid, uint16_t alt_keyid, int so_locked)
 {
struct mbuf *m_notify;
struct sctp_authkey_event *auth;

Modified: head/sys/netinet/sctp_input.c
==
--- head/sys/netinet/sctp_input.c   Thu Jun 11 12:53:22 2020
(r362053)
+++ head/sys/netinet/sctp_input.c   Thu Jun 11 13:34:09 2020
(r362054)
@@ -55,8 +55,6 @@ __FBSDID("$FreeBSD$");
 #endif
 #include 
 
-
-
 static void
 sctp_stop_all_cookie_timers(struct sctp_tcb *stcb)
 {
@@ -213,9 +211,7 @@ outnow:
  */
 
 int
-sctp_is_there_unsent_data(struct sctp_tcb *stcb, int so_locked
-SCTP_UNUSED
-)
+sctp_is_there_unsent_data(struct sctp_tcb *stcb, int so_locked)
 {
int unsent_data;
unsigned int i;

Modified: head/sys/netinet/sctp_output.c
==
--- head/sys/netinet/sctp_output.c  Thu Jun 11 12:53:22 2020
(r362053)
+++ head/sys/netinet/sctp_output.c  Thu Jun 11 13:34:09 2020
(r362054)
@@ -60,7 +60,6 @@ __FBSDID("$FreeBSD$");
 #include 
 
 
-
 #define SCTP_MAX_GAPS_INARRAY 4
 struct sack_track {
uint8_t right_edge; /* mergable on the right edge */
@@ -3990,8 +3989,7 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp,
 uint16_t port,
 union sctp_sockstore *over_addr,
 uint8_t mflowtype, uint32_t mflowid,
-int so_locked SCTP_UNUSED
-)
+int so_locked)
 {
 /* nofragment_flag to tell if IP_DF should be set (IPv4 only) */
/**
@@ -4636,9 +4634,7 @@ sctp_lowlevel_chunk_output(struct sctp_inpcb *inp,
 
 
 void
-sctp_send_initiate(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int so_locked
-SCTP_UNUSED
-)
+sctp_send_initiate(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int 
so_locked)
 {
struct mbuf *m, *m_last;
struct sctp_nets *net;
@@ -6572,9 +6568,7 @@ sctp_med_chunk_output(struct sctp_inpcb *inp,
 int *num_out,
 int *reason_code,
 int control_only, int from_where,
-struct timeval *now, int *now_filled, int frag_point, int so_locked
-SCTP_UNUSED
-);
+struct timeval *now, int *now_filled, int frag_point, int so_locked);
 
 static void
 sctp_sendall_iterator(struct sctp_inpcb *inp, struct sctp_tcb *stcb, void *ptr,
@@ -7034,9 +7028,7 @@ all_done:
 }
 
 static void
-sctp_clean_up_ctl(struct sctp_tcb *stcb, struct sctp_association *asoc, int 
so_locked
-SCTP_UNUSED
-)
+sctp_clean_up_ctl(struct sctp_tcb *stcb, struct sctp_association *asoc, int 
so_locked)
 {
struct sctp_tmit_chunk *chk, *nchk;
 
@@ -7141,9 +7133,7 @@ sctp_move_to_outqueue(struct sctp_tcb *stcb,
 int *giveup,
 int eeor_mode,
 int *bail,
-int so_locked
-SCTP_UNUSED
-)
+int so_locked)
 {
/* Move from the stream to the send_queue keeping track of the total */
struct sctp_association *asoc;
@@ -7670,9 +7660,7 @@ out_of:
 
 static void
 sctp_fill_outqueue(struct sctp_tcb *stcb,
-struct sctp_nets *net, int frag_point, int eeor_mode, int *quit_now, int 
so_locked
-SCTP_UNUSED
-)
+struct sctp_nets *net, int frag_point, int eeor_mode, int *quit_now, int 
so_locked)
 {

svn commit: r361934 - head/sys/netinet

2020-06-08 Thread Michael Tuexen
Author: tuexen
Date: Mon Jun  8 20:23:20 2020
New Revision: 361934
URL: https://svnweb.freebsd.org/changeset/base/361934

Log:
  Whitespace cleanups and removal of a stale comment.
  
  MFC after:1 week

Modified:
  head/sys/netinet/sctp_pcb.c
  head/sys/netinet/sctp_sysctl.c
  head/sys/netinet/sctputil.c

Modified: head/sys/netinet/sctp_pcb.c
==
--- head/sys/netinet/sctp_pcb.c Mon Jun  8 18:13:38 2020(r361933)
+++ head/sys/netinet/sctp_pcb.c Mon Jun  8 20:23:20 2020(r361934)
@@ -5686,7 +5686,6 @@ sctp_startup_mcore_threads(void)
i++;
}
}
-
/* Now start them all */
CPU_FOREACH(cpu) {
(void)kproc_create(sctp_mcore_thread,
@@ -5695,7 +5694,6 @@ sctp_startup_mcore_threads(void)
RFPROC,
SCTP_KTHREAD_PAGES,
SCTP_MCORE_NAME);
-
}
 }
 #endif

Modified: head/sys/netinet/sctp_sysctl.c
==
--- head/sys/netinet/sctp_sysctl.c  Mon Jun  8 18:13:38 2020
(r361933)
+++ head/sys/netinet/sctp_sysctl.c  Mon Jun  8 20:23:20 2020
(r361934)
@@ -451,7 +451,6 @@ sctp_sysctl_handle_assoclist(SYSCTL_HANDLER_ARGS)
xstcb.primary_addr = 
stcb->asoc.primary_destination->ro._l_addr;
xstcb.heartbeat_interval = stcb->asoc.heart_beat_delay;
xstcb.state = 
(uint32_t)sctp_map_assoc_state(stcb->asoc.state);
-   /* 7.0 does not support these */
xstcb.assoc_id = sctp_get_associd(stcb);
xstcb.peers_rwnd = stcb->asoc.peers_rwnd;
xstcb.in_streams = stcb->asoc.streamincnt;

Modified: head/sys/netinet/sctputil.c
==
--- head/sys/netinet/sctputil.c Mon Jun  8 18:13:38 2020(r361933)
+++ head/sys/netinet/sctputil.c Mon Jun  8 20:23:20 2020(r361934)
@@ -5565,7 +5565,6 @@ sctp_sorecvmsg(struct socket *so,
sockbuf_lock = 1;
 restart:
 
-
 restart_nosblocks:
if (hold_sblock == 0) {
SOCKBUF_LOCK(>so_rcv);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r361895 - in head/sys: netinet netinet6

2020-06-07 Thread Michael Tuexen
Author: tuexen
Date: Sun Jun  7 14:39:20 2020
New Revision: 361895
URL: https://svnweb.freebsd.org/changeset/base/361895

Log:
  Retire SCTP_SO_LOCK_TESTING.
  
  This was intended to test the locking used in the MacOS X kernel on a
  FreeBSD system, to make use of WITNESS and other debugging infrastructure.
  This hasn't been used for ages, to take it out to reduce the #ifdef
  complexity.
  
  MFC after:1 week

Modified:
  head/sys/netinet/sctp_auth.c
  head/sys/netinet/sctp_constants.h
  head/sys/netinet/sctp_indata.c
  head/sys/netinet/sctp_input.c
  head/sys/netinet/sctp_output.c
  head/sys/netinet/sctp_output.h
  head/sys/netinet/sctp_sysctl.c
  head/sys/netinet/sctp_sysctl.h
  head/sys/netinet/sctp_usrreq.c
  head/sys/netinet/sctputil.c
  head/sys/netinet/sctputil.h
  head/sys/netinet6/sctp6_usrreq.c

Modified: head/sys/netinet/sctp_auth.c
==
--- head/sys/netinet/sctp_auth.cSun Jun  7 13:53:23 2020
(r361894)
+++ head/sys/netinet/sctp_auth.cSun Jun  7 14:39:20 2020
(r361895)
@@ -566,9 +566,7 @@ sctp_auth_key_acquire(struct sctp_tcb *stcb, uint16_t 
 
 void
 sctp_auth_key_release(struct sctp_tcb *stcb, uint16_t key_id, int so_locked
-#if !defined(__APPLE__) && !defined(SCTP_SO_LOCK_TESTING)
 SCTP_UNUSED
-#endif
 )
 {
sctp_sharedkey_t *skey;
@@ -1721,9 +1719,7 @@ sctp_handle_auth(struct sctp_tcb *stcb, struct sctp_au
 void
 sctp_notify_authentication(struct sctp_tcb *stcb, uint32_t indication,
 uint16_t keyid, uint16_t alt_keyid, int so_locked
-#if !defined(__APPLE__) && !defined(SCTP_SO_LOCK_TESTING)
 SCTP_UNUSED
-#endif
 )
 {
struct mbuf *m_notify;

Modified: head/sys/netinet/sctp_constants.h
==
--- head/sys/netinet/sctp_constants.h   Sun Jun  7 13:53:23 2020
(r361894)
+++ head/sys/netinet/sctp_constants.h   Sun Jun  7 14:39:20 2020
(r361895)
@@ -943,7 +943,7 @@ __FBSDID("$FreeBSD$");
 
 /*-
  * defines for socket lock states.
- * Used by __APPLE__ and SCTP_SO_LOCK_TESTING
+ * Used by __APPLE__
  */
 #define SCTP_SO_LOCKED 1
 #define SCTP_SO_NOT_LOCKED 0

Modified: head/sys/netinet/sctp_indata.c
==
--- head/sys/netinet/sctp_indata.c  Sun Jun  7 13:53:23 2020
(r361894)
+++ head/sys/netinet/sctp_indata.c  Sun Jun  7 14:39:20 2020
(r361895)
@@ -555,20 +555,6 @@ sctp_queue_data_to_stream(struct sctp_tcb *stcb,
sctp_ucount_incr(asoc->cnt_on_all_streams);
nxt_todel = strm->last_mid_delivered + 1;
if (SCTP_MID_EQ(asoc->idata_supported, nxt_todel, control->mid)) {
-#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING)
-   struct socket *so;
-
-   so = SCTP_INP_SO(stcb->sctp_ep);
-   atomic_add_int(>asoc.refcnt, 1);
-   SCTP_TCB_UNLOCK(stcb);
-   SCTP_SOCKET_LOCK(so, 1);
-   SCTP_TCB_LOCK(stcb);
-   atomic_subtract_int(>asoc.refcnt, 1);
-   if (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE) {
-   SCTP_SOCKET_UNLOCK(so, 1);
-   return;
-   }
-#endif
/* can be delivered right away? */
if (SCTP_BASE_SYSCTL(sctp_logging_level) & 
SCTP_STR_LOGGING_ENABLE) {
sctp_log_strm_del(control, NULL, 
SCTP_STR_LOG_FROM_IMMED_DEL);
@@ -638,9 +624,6 @@ sctp_queue_data_to_stream(struct sctp_tcb *stcb,
}
break;
}
-#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING)
-   SCTP_SOCKET_UNLOCK(so, 1);
-#endif
}
if (queue_needed) {
/*
@@ -1956,25 +1939,7 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struc
 */
if (stcb->sctp_socket->so_rcv.sb_cc) {
/* some to read, wake-up */
-#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING)
-   struct socket *so;
-
-   so = SCTP_INP_SO(stcb->sctp_ep);
-   atomic_add_int(>asoc.refcnt, 1);
-   SCTP_TCB_UNLOCK(stcb);
-   SCTP_SOCKET_LOCK(so, 1);
-   SCTP_TCB_LOCK(stcb);
-   atomic_subtract_int(>asoc.refcnt, 1);
-   if (stcb->asoc.state & SCTP_STATE_CLOSED_SOCKET) {
-   /* assoc was freed while we were unlocked */
-   SCTP_SOCKET_UNLOCK(so, 1);
-   return (0);
-   }
-#endif
sctp_sorwakeup(stcb->sctp_ep, stcb->sctp_socket);
-#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING)
-   SCTP_SOCKET_UNLOCK(so, 1);
-#endif
}

svn commit: r361877 - head/sys/netinet

2020-06-06 Thread Michael Tuexen
Author: tuexen
Date: Sat Jun  6 21:26:34 2020
New Revision: 361877
URL: https://svnweb.freebsd.org/changeset/base/361877

Log:
  Fix typo in comment.
  
  Submitted by Orgad Shaneh for the userland stack.
  MFC after:1 week

Modified:
  head/sys/netinet/sctp_pcb.c

Modified: head/sys/netinet/sctp_pcb.c
==
--- head/sys/netinet/sctp_pcb.c Sat Jun  6 21:07:50 2020(r361876)
+++ head/sys/netinet/sctp_pcb.c Sat Jun  6 21:26:34 2020(r361877)
@@ -5881,7 +5881,7 @@ retry:
 * holding the lock.  We won't find it on the list either and
 * continue and free/destroy it.  While holding the lock, spin, to
 * avoid the race condition as sctp_iterator_worker() will have to
-* wait to re-aquire the lock.
+* wait to re-acquire the lock.
 */
if (sctp_it_ctl.iterator_running != 0 || sctp_it_ctl.cur_it != NULL) {
SCTP_IPI_ITERATOR_WQ_UNLOCK();
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r361872 - head/sys/netinet

2020-06-06 Thread Michael Tuexen
> On 6. Jun 2020, at 20:56, Kevin Bowling  wrote:
> 
> Out of curiosity what is panda?
Hi Kevin,

it was the name used (#ifdef __Panda__) in the upstream SCTP code for
using it in an Cisco proprietary product.
Since I don't know if that code is still used, but they haven't
contributed anything back, I think it is OK to reduce the #ifdef complexity
upstream and remove it. 

Best regards
Michael
> 
> On Sat, Jun 6, 2020 at 11:20 AM Michael Tuexen  wrote:
>> 
>> Author: tuexen
>> Date: Sat Jun  6 18:20:09 2020
>> New Revision: 361872
>> URL: https://svnweb.freebsd.org/changeset/base/361872
>> 
>> Log:
>>  Non-functional changes due to cleanup (upstream removing of Panda support)
>>  of the code
>> 
>>  MFC after:1 week
>> 
>> Modified:
>>  head/sys/netinet/sctp_constants.h
>>  head/sys/netinet/sctp_indata.c
>>  head/sys/netinet/sctp_os.h
>>  head/sys/netinet/sctp_output.c
>>  head/sys/netinet/sctp_pcb.c
>>  head/sys/netinet/sctp_usrreq.c
>> 
>> Modified: head/sys/netinet/sctp_constants.h
>> ==
>> --- head/sys/netinet/sctp_constants.h   Sat Jun  6 17:48:55 2020
>> (r361871)
>> +++ head/sys/netinet/sctp_constants.h   Sat Jun  6 18:20:09 2020
>> (r361872)
>> @@ -576,7 +576,6 @@ __FBSDID("$FreeBSD$");
>>  */
>> #define SCTP_ASOC_MAX_CHUNKS_ON_QUEUE 512
>> 
>> -
>> /*
>>  * Basically the minimum amount of time before I do a early FR. Making this
>>  * value to low will cause duplicate retransmissions.
>> @@ -756,9 +755,8 @@ __FBSDID("$FreeBSD$");
>> #define SCTP_FROM_SCTP_ASCONF   0x8000
>> #define SCTP_FROM_SCTP_OUTPUT   0x9000
>> #define SCTP_FROM_SCTP_PEELOFF  0xa000
>> -#define SCTP_FROM_SCTP_PANDA0xb000
>> -#define SCTP_FROM_SCTP_SYSCTL   0xc000
>> -#define SCTP_FROM_SCTP_CC_FUNCTIONS 0xd000
>> +#define SCTP_FROM_SCTP_SYSCTL   0xb000
>> +#define SCTP_FROM_SCTP_CC_FUNCTIONS 0xc000
>> 
>> /* Location ID's */
>> #define SCTP_LOC_1  0x0001
>> 
>> Modified: head/sys/netinet/sctp_indata.c
>> ==
>> --- head/sys/netinet/sctp_indata.c  Sat Jun  6 17:48:55 2020
>> (r361871)
>> +++ head/sys/netinet/sctp_indata.c  Sat Jun  6 18:20:09 2020
>> (r361872)
>> @@ -2721,8 +2721,7 @@ sctp_process_data(struct mbuf **mm, int iphlen, int *o
>> * cluster... i.e. it is a small packet sent in and yet the driver
>> * underneath allocated a full cluster for it. If so we must copy it
>> * to a smaller mbuf and free up the cluster mbuf. This will help
>> -* with cluster starvation. Note for __Panda__ we don't do this
>> -* since it has clusters all the way down to 64 bytes.
>> +* with cluster starvation.
>> */
>>if (SCTP_BUF_LEN(m) < (long)MLEN && SCTP_BUF_NEXT(m) == NULL) {
>>/* we only handle mbufs that are singletons.. not chains */
>> 
>> Modified: head/sys/netinet/sctp_os.h
>> ==
>> --- head/sys/netinet/sctp_os.h  Sat Jun  6 17:48:55 2020(r361871)
>> +++ head/sys/netinet/sctp_os.h  Sat Jun  6 18:20:09 2020(r361872)
>> @@ -67,7 +67,6 @@ __FBSDID("$FreeBSD$");
>> 
>> 
>> 
>> -
>> /* All os's must implement this address gatherer. If
>>  * no VRF's exist, then vrf 0 is the only one and all
>>  * addresses and ifn's live here.
>> 
>> Modified: head/sys/netinet/sctp_output.c
>> ==
>> --- head/sys/netinet/sctp_output.c  Sat Jun  6 17:48:55 2020
>> (r361871)
>> +++ head/sys/netinet/sctp_output.c  Sat Jun  6 18:20:09 2020
>> (r361872)
>> @@ -6475,8 +6475,7 @@ error_out:
>>appendchain = clonechain;
>>} else {
>>if (!copy_by_ref &&
>> -   (sizeofcpy <= 
>> (int)SCTP_BASE_SYSCTL(sctp_mbuf_threshold_count) - 1) * MLEN) + MHLEN)))
>> -   ) {
>> +   (sizeofcpy <= 
>> (int)SCTP_BASE_SYSCTL(sctp_mbuf_threshold_count) - 1) * MLEN) + 
>> MHLEN {
>>/* Its not in a cluster */
>>if (*endofchain == NULL) {
&g

svn commit: r361872 - head/sys/netinet

2020-06-06 Thread Michael Tuexen
Author: tuexen
Date: Sat Jun  6 18:20:09 2020
New Revision: 361872
URL: https://svnweb.freebsd.org/changeset/base/361872

Log:
  Non-functional changes due to cleanup (upstream removing of Panda support)
  of the code
  
  MFC after:1 week

Modified:
  head/sys/netinet/sctp_constants.h
  head/sys/netinet/sctp_indata.c
  head/sys/netinet/sctp_os.h
  head/sys/netinet/sctp_output.c
  head/sys/netinet/sctp_pcb.c
  head/sys/netinet/sctp_usrreq.c

Modified: head/sys/netinet/sctp_constants.h
==
--- head/sys/netinet/sctp_constants.h   Sat Jun  6 17:48:55 2020
(r361871)
+++ head/sys/netinet/sctp_constants.h   Sat Jun  6 18:20:09 2020
(r361872)
@@ -576,7 +576,6 @@ __FBSDID("$FreeBSD$");
  */
 #define SCTP_ASOC_MAX_CHUNKS_ON_QUEUE 512
 
-
 /*
  * Basically the minimum amount of time before I do a early FR. Making this
  * value to low will cause duplicate retransmissions.
@@ -756,9 +755,8 @@ __FBSDID("$FreeBSD$");
 #define SCTP_FROM_SCTP_ASCONF   0x8000
 #define SCTP_FROM_SCTP_OUTPUT   0x9000
 #define SCTP_FROM_SCTP_PEELOFF  0xa000
-#define SCTP_FROM_SCTP_PANDA0xb000
-#define SCTP_FROM_SCTP_SYSCTL   0xc000
-#define SCTP_FROM_SCTP_CC_FUNCTIONS 0xd000
+#define SCTP_FROM_SCTP_SYSCTL   0xb000
+#define SCTP_FROM_SCTP_CC_FUNCTIONS 0xc000
 
 /* Location ID's */
 #define SCTP_LOC_1  0x0001

Modified: head/sys/netinet/sctp_indata.c
==
--- head/sys/netinet/sctp_indata.c  Sat Jun  6 17:48:55 2020
(r361871)
+++ head/sys/netinet/sctp_indata.c  Sat Jun  6 18:20:09 2020
(r361872)
@@ -2721,8 +2721,7 @@ sctp_process_data(struct mbuf **mm, int iphlen, int *o
 * cluster... i.e. it is a small packet sent in and yet the driver
 * underneath allocated a full cluster for it. If so we must copy it
 * to a smaller mbuf and free up the cluster mbuf. This will help
-* with cluster starvation. Note for __Panda__ we don't do this
-* since it has clusters all the way down to 64 bytes.
+* with cluster starvation.
 */
if (SCTP_BUF_LEN(m) < (long)MLEN && SCTP_BUF_NEXT(m) == NULL) {
/* we only handle mbufs that are singletons.. not chains */

Modified: head/sys/netinet/sctp_os.h
==
--- head/sys/netinet/sctp_os.h  Sat Jun  6 17:48:55 2020(r361871)
+++ head/sys/netinet/sctp_os.h  Sat Jun  6 18:20:09 2020(r361872)
@@ -67,7 +67,6 @@ __FBSDID("$FreeBSD$");
 
 
 
-
 /* All os's must implement this address gatherer. If
  * no VRF's exist, then vrf 0 is the only one and all
  * addresses and ifn's live here.

Modified: head/sys/netinet/sctp_output.c
==
--- head/sys/netinet/sctp_output.c  Sat Jun  6 17:48:55 2020
(r361871)
+++ head/sys/netinet/sctp_output.c  Sat Jun  6 18:20:09 2020
(r361872)
@@ -6475,8 +6475,7 @@ error_out:
appendchain = clonechain;
} else {
if (!copy_by_ref &&
-   (sizeofcpy <= 
(int)SCTP_BASE_SYSCTL(sctp_mbuf_threshold_count) - 1) * MLEN) + MHLEN)))
-   ) {
+   (sizeofcpy <= 
(int)SCTP_BASE_SYSCTL(sctp_mbuf_threshold_count) - 1) * MLEN) + MHLEN {
/* Its not in a cluster */
if (*endofchain == NULL) {
/* lets get a mbuf cluster */
@@ -13526,12 +13525,6 @@ skip_preblock:
error = sctp_msg_append(stcb, net, top, srcv, 0);
top = NULL;
if (sinfo_flags & SCTP_EOF) {
-   /*
-* This should only happen for Panda for the mbuf
-* send case, which does NOT yet support EEOR mode.
-* Thus, we can just set this flag to do the proper
-* EOF handling.
-*/
got_all_of_the_send = 1;
}
}

Modified: head/sys/netinet/sctp_pcb.c
==
--- head/sys/netinet/sctp_pcb.c Sat Jun  6 17:48:55 2020(r361871)
+++ head/sys/netinet/sctp_pcb.c Sat Jun  6 18:20:09 2020(r361872)
@@ -749,8 +749,7 @@ sctp_del_addr_from_vrf(uint32_t vrf_id, struct sockadd
 
/*-
 * The name has priority over the ifn_index
-* if its given. We do this especially for
-* panda who might recycle indexes fast.
+* if its given.
 */
if (if_name) {
if (strncmp(if_name, 

svn commit: r361750 - head/sys/netinet

2020-06-03 Thread Michael Tuexen
Author: tuexen
Date: Wed Jun  3 13:51:53 2020
New Revision: 361750
URL: https://svnweb.freebsd.org/changeset/base/361750

Log:
  Restrict enabling TCP-FASTOPEN to end-points in CLOSED or LISTEN state
  
  Enabling TCP-FASTOPEN on an end-point which is in a state other than
  CLOSED or LISTEN, is a bug in the application. So it should not work.
  Also the TCP code does not (and needs not to) handle this.
  While there, also simplify the setting of the TF_FASTOPEN flag.
  
  This issue was found by running syzkaller.
  
  Reviewed by:  rrs
  MFC after:1 week
  Sponsored by: Netflix, Inc.
  Differential Revision:https://reviews.freebsd.org/D25115

Modified:
  head/sys/netinet/tcp_usrreq.c

Modified: head/sys/netinet/tcp_usrreq.c
==
--- head/sys/netinet/tcp_usrreq.c   Wed Jun  3 13:02:31 2020
(r361749)
+++ head/sys/netinet/tcp_usrreq.c   Wed Jun  3 13:51:53 2020
(r361750)
@@ -2239,6 +2239,11 @@ unlock_and_done:
return (error);
 
INP_WLOCK_RECHECK(inp);
+   if ((tp->t_state != TCPS_CLOSED) &&
+   (tp->t_state != TCPS_LISTEN)) {
+   error = EINVAL;
+   goto unlock_and_done;
+   }
if (tfo_optval.enable) {
if (tp->t_state == TCPS_LISTEN) {
if (!V_tcp_fastopen_server_enable) {
@@ -2246,7 +2251,6 @@ unlock_and_done:
goto unlock_and_done;
}
 
-   tp->t_flags |= TF_FASTOPEN;
if (tp->t_tfo_pending == NULL)
tp->t_tfo_pending =

tcp_fastopen_alloc_counter();
@@ -2265,8 +2269,8 @@ unlock_and_done:
tp->t_tfo_client_cookie_len =
TCP_FASTOPEN_PSK_LEN;
}
-   tp->t_flags |= TF_FASTOPEN;
}
+   tp->t_flags |= TF_FASTOPEN;
} else
tp->t_flags &= ~TF_FASTOPEN;
goto unlock_and_done;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r361706 - in head/sys: net net/route netinet netinet6

2020-06-01 Thread Michael Tuexen
> On 1. Jun 2020, at 22:49, Alexander V. Chernikov  wrote:
> 
> Author: melifaro
> Date: Mon Jun  1 20:49:42 2020
> New Revision: 361706
> URL: https://svnweb.freebsd.org/changeset/base/361706
> 
> Log:
>  * Add rib__route() functions to manipulate the routing table.
> 
>  The main driver for the change is the need to improve notification mechanism.
>  Currently callers guess the operation data based on the rtentry structure
>   returned in case of successful operation result. There are two problems with
>   this appoach. First is that it doesn't provide enough information for the
>   upcoming multipath changes, where rtentry refers to a new nexthop group,
>   and there is no way of guessing which paths were added during the change.
>   Second is that some rtentry fields can change during notification and
>   protecting from it by requiring customers to unlock rtentry is not desired.
> 
>  Additionally, as the consumers such as rtsock do know which operation they
>   request in advance, making explicit add/change/del versions of the functions
>   makes sense, especially given the functions don't share a lot of code.
> 
>  With that in mind, introduce rib_cmd_info notification structure and
>   rib__route() functions, with mandatory rib_cmd_info pointer.
>   It will be used in upcoming generalized notifications.
> 
>  * Move definitions of the new functions and some other functions/structures
>   used for the routing table manipulation to a separate header file,
>   net/route/route_ctl.h. net/route.h is a frequently used file included in
>   ~140 places in kernel, and 90% of the users don't need these definitions.
> 
>  Reviewed by: ae
>  Differential Revision:   https://reviews.freebsd.org/D25067
> 
> Modified:
>  head/sys/net/if_llatbl.c
>  head/sys/net/route.c
>  head/sys/net/route.h
>  head/sys/net/route/nhop_ctl.c
>  head/sys/net/route/route_ctl.c
>  head/sys/net/route/route_ddb.c
>  head/sys/net/route/route_helpers.c
>  head/sys/net/route/route_temporal.c
>  head/sys/net/route/route_var.h
>  head/sys/netinet/in_rmx.c
>  head/sys/netinet/ip_icmp.c
>  head/sys/netinet6/icmp6.c
>  head/sys/netinet6/in6_rmx.c
>  head/sys/netinet6/nd6_rtr.c
> 
> Modified: head/sys/net/if_llatbl.c
> ==
> --- head/sys/net/if_llatbl.c  Mon Jun  1 20:40:40 2020(r361705)
> +++ head/sys/net/if_llatbl.c  Mon Jun  1 20:49:42 2020(r361706)
> @@ -58,6 +58,7 @@ __FBSDID("$FreeBSD$");
> #include 
> #include 
> #include 
> +#include 
Where is this file coming from?

Best regards
Michael
> #include 
> #include 
> #include 
> 
> Modified: head/sys/net/route.c
> ==
> --- head/sys/net/route.c  Mon Jun  1 20:40:40 2020(r361705)
> +++ head/sys/net/route.c  Mon Jun  1 20:49:42 2020(r361706)
> @@ -61,6 +61,7 @@
> #include 
> #include 
> #include 
> +#include 
> #include 
> #include 
> #include 
> @@ -346,6 +347,9 @@ rt_table_init(int offset, int family, u_int fibnum)
> 
>   nhops_init_rib(rh);
> 
> + /* Init subscription system */
> + CK_STAILQ_INIT(>rnh_subscribers);
> +
>   /* Finally, set base callbacks */
>   rh->rnh_addaddr = rn_addroute;
>   rh->rnh_deladdr = rn_delete;
> @@ -1148,6 +1152,7 @@ rtrequest1_fib(int req, struct rt_addrinfo *info, stru
> {
>   const struct sockaddr *dst;
>   struct rib_head *rnh;
> + struct rib_cmd_info rc;
>   int error;
> 
>   KASSERT((fibnum < rt_numfibs), ("rtrequest1_fib: bad fibnum"));
> @@ -1180,10 +1185,11 @@ rtrequest1_fib(int req, struct rt_addrinfo *info, stru
>   if (info->rti_flags & RTF_HOST)
>   info->rti_info[RTAX_NETMASK] = NULL;
> 
> + bzero(, sizeof(struct rib_cmd_info));
>   error = 0;
>   switch (req) {
>   case RTM_DELETE:
> - error = del_route(rnh, info, ret_nrt);
> + error = del_route(rnh, info, );
>   break;
>   case RTM_RESOLVE:
>   /*
> @@ -1192,14 +1198,17 @@ rtrequest1_fib(int req, struct rt_addrinfo *info, stru
>*/
>   break;
>   case RTM_ADD:
> - error = add_route(rnh, info, ret_nrt);
> + error = add_route(rnh, info, );
>   break;
>   case RTM_CHANGE:
> - error = change_route(rnh, info, ret_nrt);
> + error = change_route(rnh, info, );
>   break;
>   default:
>   error = EOPNOTSUPP;
>   }
> +
> + if (ret_nrt != NULL)
> + *ret_nrt = rc.rc_rt;
> 
>   return (error);
> }
> 
> Modified: head/sys/net/route.h
> ==
> --- head/sys/net/route.h  Mon Jun  1 20:40:40 2020(r361705)
> +++ head/sys/net/route.h  Mon Jun  1 20:49:42 2020(r361706)
> @@ -399,12 +399,6 @@ void  rtfree(struct rtentry *);
> void   

svn commit: r361243 - head/sys/netinet

2020-05-19 Thread Michael Tuexen
Author: tuexen
Date: Tue May 19 07:23:35 2020
New Revision: 361243
URL: https://svnweb.freebsd.org/changeset/base/361243

Log:
  Replace snprintf() by SCTP_SNPRINTF() and let SCTP_SNPRINTF() map
  to snprintf() on FreeBSD. This allows to check for failures of snprintf()
  on platforms other than FreeBSD kernel.

Modified:
  head/sys/netinet/sctp_asconf.c
  head/sys/netinet/sctp_indata.c
  head/sys/netinet/sctp_input.c
  head/sys/netinet/sctp_os_bsd.h
  head/sys/netinet/sctp_output.c
  head/sys/netinet/sctp_pcb.c

Modified: head/sys/netinet/sctp_asconf.c
==
--- head/sys/netinet/sctp_asconf.c  Tue May 19 07:21:11 2020
(r361242)
+++ head/sys/netinet/sctp_asconf.c  Tue May 19 07:23:35 2020
(r361243)
@@ -1706,8 +1706,7 @@ sctp_handle_asconf_ack(struct mbuf *m, int offset,
char msg[SCTP_DIAG_INFO_LEN];
 
SCTPDBG(SCTP_DEBUG_ASCONF1, "handle_asconf_ack: got unexpected 
next serial number! Aborting asoc!\n");
-   snprintf(msg, sizeof(msg), "Never sent serial number %8.8x",
-   serial_num);
+   SCTP_SNPRINTF(msg, sizeof(msg), "Never sent serial number 
%8.8x", serial_num);
op_err = sctp_generate_cause(SCTP_CAUSE_PROTOCOL_VIOLATION, 
msg);
sctp_abort_an_association(stcb->sctp_ep, stcb, op_err, 
SCTP_SO_NOT_LOCKED);
*abort_no_unlock = 1;

Modified: head/sys/netinet/sctp_indata.c
==
--- head/sys/netinet/sctp_indata.c  Tue May 19 07:21:11 2020
(r361242)
+++ head/sys/netinet/sctp_indata.c  Tue May 19 07:23:35 2020
(r361243)
@@ -434,7 +434,7 @@ sctp_abort_in_reasm(struct sctp_tcb *stcb,
struct mbuf *oper;
 
if (stcb->asoc.idata_supported) {
-   snprintf(msg, sizeof(msg),
+   SCTP_SNPRINTF(msg, sizeof(msg),
"Reass %x,CF:%x,TSN=%8.8x,SID=%4.4x,FSN=%8.8x,MID:%8.8x",
opspot,
control->fsn_included,
@@ -442,7 +442,7 @@ sctp_abort_in_reasm(struct sctp_tcb *stcb,
chk->rec.data.sid,
chk->rec.data.fsn, chk->rec.data.mid);
} else {
-   snprintf(msg, sizeof(msg),
+   SCTP_SNPRINTF(msg, sizeof(msg),
"Reass %x,CI:%x,TSN=%8.8x,SID=%4.4x,FSN=%4.4x,SSN:%4.4x",
opspot,
control->fsn_included,
@@ -533,11 +533,11 @@ sctp_queue_data_to_stream(struct sctp_tcb *stcb,
 */
TAILQ_INSERT_HEAD(>inqueue, control, next_instrm);
if (asoc->idata_supported) {
-   snprintf(msg, sizeof(msg), "Delivered MID=%8.8x, got 
TSN=%8.8x, SID=%4.4x, MID=%8.8x",
+   SCTP_SNPRINTF(msg, sizeof(msg), "Delivered MID=%8.8x, 
got TSN=%8.8x, SID=%4.4x, MID=%8.8x",
strm->last_mid_delivered, control->sinfo_tsn,
control->sinfo_stream, control->mid);
} else {
-   snprintf(msg, sizeof(msg), "Delivered SSN=%4.4x, got 
TSN=%8.8x, SID=%4.4x, SSN=%4.4x",
+   SCTP_SNPRINTF(msg, sizeof(msg), "Delivered SSN=%4.4x, 
got TSN=%8.8x, SID=%4.4x, SSN=%4.4x",
(uint16_t)strm->last_mid_delivered,
control->sinfo_tsn,
control->sinfo_stream,
@@ -648,9 +648,8 @@ sctp_queue_data_to_stream(struct sctp_tcb *stcb,
 * to put it on the queue.
 */
if (sctp_place_control_in_stream(strm, asoc, control)) {
-   snprintf(msg, sizeof(msg),
-   "Queue to str MID: %u duplicate",
-   control->mid);
+   SCTP_SNPRINTF(msg, sizeof(msg),
+   "Queue to str MID: %u duplicate", control->mid);
sctp_clean_up_control(stcb, control);
op_err = 
sctp_generate_cause(SCTP_CAUSE_PROTOCOL_VIOLATION, msg);
stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_INDATA 
+ SCTP_LOC_3;
@@ -1881,8 +1880,7 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struc
 * can *not* be fsn 0. XXX: This can happen in case of a
 * wrap around. Ignore is for now.
 */
-   snprintf(msg, sizeof(msg), "FSN zero for MID=%8.8x, but 
flags=%2.2x",
-   mid, chk_flags);
+   SCTP_SNPRINTF(msg, sizeof(msg), "FSN zero for MID=%8.8x, but 
flags=%2.2x", mid, chk_flags);
goto err_out;
}
control = sctp_find_reasm_entry(>strmin[sid], mid, ordered, 
asoc->idata_supported);
@@ -1893,7 +1891,7 @@ sctp_process_a_data_chunk(struct sctp_tcb *stcb, struc
if (control != NULL) {
 

svn commit: r361242 - head/sys/netinet

2020-05-19 Thread Michael Tuexen
Author: tuexen
Date: Tue May 19 07:21:11 2020
New Revision: 361242
URL: https://svnweb.freebsd.org/changeset/base/361242

Log:
  Revert r361209:
  
  cem noted that on FreeBSD snprintf() can not fail and code should not
  check for that.
  
  A followup commit will replace the usage of snprintf() in the SCTP
  sources with a variadic macro SCTP_SNPRINTF, which will simply map to
  snprintf() on FreeBSD and do a checking similar to r361209 on
  other platforms.

Modified:
  head/sys/netinet/sctp_asconf.c
  head/sys/netinet/sctp_indata.c
  head/sys/netinet/sctp_input.c
  head/sys/netinet/sctp_output.c
  head/sys/netinet/sctp_pcb.c

Modified: head/sys/netinet/sctp_asconf.c
==
--- head/sys/netinet/sctp_asconf.c  Tue May 19 07:16:09 2020
(r361241)
+++ head/sys/netinet/sctp_asconf.c  Tue May 19 07:21:11 2020
(r361242)
@@ -1706,9 +1706,8 @@ sctp_handle_asconf_ack(struct mbuf *m, int offset,
char msg[SCTP_DIAG_INFO_LEN];
 
SCTPDBG(SCTP_DEBUG_ASCONF1, "handle_asconf_ack: got unexpected 
next serial number! Aborting asoc!\n");
-   if (snprintf(msg, sizeof(msg), "Never sent serial number 
%8.8x", serial_num) < 0) {
-   msg[0] = '\0';
-   }
+   snprintf(msg, sizeof(msg), "Never sent serial number %8.8x",
+   serial_num);
op_err = sctp_generate_cause(SCTP_CAUSE_PROTOCOL_VIOLATION, 
msg);
sctp_abort_an_association(stcb->sctp_ep, stcb, op_err, 
SCTP_SO_NOT_LOCKED);
*abort_no_unlock = 1;

Modified: head/sys/netinet/sctp_indata.c
==
--- head/sys/netinet/sctp_indata.c  Tue May 19 07:16:09 2020
(r361241)
+++ head/sys/netinet/sctp_indata.c  Tue May 19 07:21:11 2020
(r361242)
@@ -434,26 +434,22 @@ sctp_abort_in_reasm(struct sctp_tcb *stcb,
struct mbuf *oper;
 
if (stcb->asoc.idata_supported) {
-   if (snprintf(msg, sizeof(msg),
+   snprintf(msg, sizeof(msg),
"Reass %x,CF:%x,TSN=%8.8x,SID=%4.4x,FSN=%8.8x,MID:%8.8x",
opspot,
control->fsn_included,
chk->rec.data.tsn,
chk->rec.data.sid,
-   chk->rec.data.fsn, chk->rec.data.mid) < 0) {
-   msg[0] = '\0';
-   }
+   chk->rec.data.fsn, chk->rec.data.mid);
} else {
-   if (snprintf(msg, sizeof(msg),
+   snprintf(msg, sizeof(msg),
"Reass %x,CI:%x,TSN=%8.8x,SID=%4.4x,FSN=%4.4x,SSN:%4.4x",
opspot,
control->fsn_included,
chk->rec.data.tsn,
chk->rec.data.sid,
chk->rec.data.fsn,
-   (uint16_t)chk->rec.data.mid) < 0) {
-   msg[0] = '\0';
-   }
+   (uint16_t)chk->rec.data.mid);
}
oper = sctp_generate_cause(SCTP_CAUSE_PROTOCOL_VIOLATION, msg);
sctp_m_freem(chk->data);
@@ -537,19 +533,15 @@ sctp_queue_data_to_stream(struct sctp_tcb *stcb,
 */
TAILQ_INSERT_HEAD(>inqueue, control, next_instrm);
if (asoc->idata_supported) {
-   if (snprintf(msg, sizeof(msg), "Delivered MID=%8.8x, 
got TSN=%8.8x, SID=%4.4x, MID=%8.8x",
+   snprintf(msg, sizeof(msg), "Delivered MID=%8.8x, got 
TSN=%8.8x, SID=%4.4x, MID=%8.8x",
strm->last_mid_delivered, control->sinfo_tsn,
-   control->sinfo_stream, control->mid) < 0) {
-   msg[0] = '\0';
-   }
+   control->sinfo_stream, control->mid);
} else {
-   if (snprintf(msg, sizeof(msg), "Delivered SSN=%4.4x, 
got TSN=%8.8x, SID=%4.4x, SSN=%4.4x",
+   snprintf(msg, sizeof(msg), "Delivered SSN=%4.4x, got 
TSN=%8.8x, SID=%4.4x, SSN=%4.4x",
(uint16_t)strm->last_mid_delivered,
control->sinfo_tsn,
control->sinfo_stream,
-   (uint16_t)control->mid) < 0) {
-   msg[0] = '\0';
-   }
+   (uint16_t)control->mid);
}
op_err = sctp_generate_cause(SCTP_CAUSE_PROTOCOL_VIOLATION, 
msg);
stcb->sctp_ep->last_abort_code = SCTP_FROM_SCTP_INDATA + 
SCTP_LOC_2;
@@ -656,10 +648,9 @@ sctp_queue_data_to_stream(struct sctp_tcb *stcb,
 * to put it on the queue.
 */
if (sctp_place_control_in_stream(strm, asoc, control)) {
-   if (snprintf(msg, sizeof(msg),
-  

Re: svn commit: r361209 - head/sys/netinet

2020-05-18 Thread Michael Tuexen
> On 18. May 2020, at 23:09, Ian Lepore  wrote:
> 
> On Mon, 2020-05-18 at 23:01 +0200, Michael Tuexen wrote:
>>> On 18. May 2020, at 22:48, Ian Lepore  wrote:
>>> 
>>> On Mon, 2020-05-18 at 22:43 +0200, Michael Tuexen wrote:
>>>>> Sure.  You can certainly ignore user reports corresponding to
>>>>> bogus
>>>>> flags, though, and encourage use of various flags.
>>>> 
>>>> I could, but decided to improve the situation for some people,
>>>> but
>>>> wasn't realising that I made it worse for others. Sorry about
>>>> that.
>>> 
>>> I'm trying to figure out why your original commit was a problem.  I
>>> understand why it was questioned, but once the answer came out,
>>> it's
>>> clear that the code you originally committed does what it's
>>> supposed to
>>> without any harmful side effects.  Sure, freebsd doesn't strictly
>>> need
>> 
>> I guess the point Conrad is making, that on FreeBSD the check is not
>> needed, since the call can not fail. So the FreeBSD code base would
>> not
>> be consistent: within the SCTP related code the return code is
>> checked,
>> in the other code it is not.
>>> it, but the code is shared among projects, so what's the harm in
>>> the
>>> extra check that helps other projects sharing the code?  It's
>>> certainly
>>> a lot less confusion and code clutter than any of the "remedies"
>>> that
>>> have been discussed.
>> 
>> Yepp, sharing code between platforms makes things harder. Running the
>> same
>> code in kernel land and userland does not make it simpler. Different
>> groups
>> have different opinions/styles/...
>> 
>> I'll revert the commit tomorrow and a variadic macros
>> SCTP_SNPRINTF(), which
>> will map on FreeBSD to snprintf() and on the other platforms will do
>> the check.
>> 
>> If the build problem comes up on FreeBSD userland (and I have no idea
>> if that
>> is the case, since I don't know how Firefox / Chrome are build on
>> FreeBSD),
>> I leave it up to the port maintainer of the application to deal with
>> it.
>> 
>> Best regards
>> Michael
>>> 
>>> -- Ian
>>> 
>> 
>> 
> 
> Well it seems to me you're being asked to do a lot of extra work that
> has the final result of making the code LESS clear and MORE complex,
> because of one person's opinion.  I'm actually a bit tempted to
Yes, it is one person. But it is one person who thinks the change
is bad enough that he needs to speak up. So I think this has to be
addressed.
> complain about the change, because to me it reduces rather than
> improves code quality.
Well, we have abstracted from FreeBSD specifics by using macros in
other cases as well.

Adding another macro will make reading a bit harder and you have
to lookup the platform specific implementation of the code to
figure out what is going on, but that way, I guess, people will
get a result they can live with.

Best regards
Michael
> 
> -- Ian
> 
> 

___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r361209 - head/sys/netinet

2020-05-18 Thread Michael Tuexen
> On 18. May 2020, at 22:48, Ian Lepore  wrote:
> 
> On Mon, 2020-05-18 at 22:43 +0200, Michael Tuexen wrote:
>>> Sure.  You can certainly ignore user reports corresponding to bogus
>>> flags, though, and encourage use of various flags.
>> 
>> I could, but decided to improve the situation for some people, but
>> wasn't realising that I made it worse for others. Sorry about that.
> 
> I'm trying to figure out why your original commit was a problem.  I
> understand why it was questioned, but once the answer came out, it's
> clear that the code you originally committed does what it's supposed to
> without any harmful side effects.  Sure, freebsd doesn't strictly need
I guess the point Conrad is making, that on FreeBSD the check is not
needed, since the call can not fail. So the FreeBSD code base would not
be consistent: within the SCTP related code the return code is checked,
in the other code it is not.
> it, but the code is shared among projects, so what's the harm in the
> extra check that helps other projects sharing the code?  It's certainly
> a lot less confusion and code clutter than any of the "remedies" that
> have been discussed.
Yepp, sharing code between platforms makes things harder. Running the same
code in kernel land and userland does not make it simpler. Different groups
have different opinions/styles/...

I'll revert the commit tomorrow and a variadic macros SCTP_SNPRINTF(), which
will map on FreeBSD to snprintf() and on the other platforms will do the check.

If the build problem comes up on FreeBSD userland (and I have no idea if that
is the case, since I don't know how Firefox / Chrome are build on FreeBSD),
I leave it up to the port maintainer of the application to deal with it.

Best regards
Michael
> 
> -- Ian
> 

___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r361209 - head/sys/netinet

2020-05-18 Thread Michael Tuexen
> On 18. May 2020, at 22:17, Conrad Meyer  wrote:
> 
> Hi Michael,
> 
> On Mon, May 18, 2020 at 12:05 PM Michael Tuexen  wrote:
>> 
>>> On 18. May 2020, at 20:23, Conrad Meyer  wrote:
>> 
>>> If truncation is intended, the GCC warning is spurious.  Given how
>>> often snprintf is used in this way, I wonder if it would make sense to
>>> just disable it across the entire tree.  Regardless, IMO it makes
>> 
>> The issue wasn't reported against the kernel code, but running the code
>> in userland. I don't really control the flags people are using.
> 
> Sure.  You can certainly ignore user reports corresponding to bogus
> flags, though, and encourage use of various flags.
I could, but decided to improve the situation for some people, but
wasn't realising that I made it worse for others. Sorry about that.
> 
>> OK. I'll revert this change and replace it upstream by something like
>> 
>> #if defined(__FreeBSD_)
>>snprintf(msg, sizeof(msg), "Never sent serial number %8.8x", 
>> serial_num)
>> #else
>>if (snprintf(msg, sizeof(msg), "Never sent serial number %8.8x", 
>> serial_num) < 0) {
>>msg[0] = '\0';
>>}
>> #endif
> 
> This seems like a messy solution.  I'd suggest either putting
> unconditional "msg[0] = '\0';" before snprintf() invocations, or
That would assume that in case of an error the first byte is overwitten.
> defining an snprintf wrapper function for non-FreeBSD platforms and
> using it universally.
Yeah, one can use a Macro SCTP_SNPRINTF(). Let me see...
> 
>> I don't know if other platforms guarantee that snprintf() can't fail.
>> If it fails, the stack would send out un-initialized stack memory on
>> the network.
> 
> Sure, that's a good concern.  That said,
> 
> Glibc: 
> https://github.com/bminor/glibc/blob/5f72f9800b250410cad3abfeeb09469ef12b2438/libio/vsnprintf.c#L93-L114
> (always nul terminates)
> MS: 
> https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/snprintf-snprintf-snprintf-l-snwprintf-snwprintf-l?view=vs-2019
> ("The snprintf function always stores a terminating null character…")
> OpenBSD: 
> https://github.com/openbsd/src/blob/master/lib/libc/stdio/vsnprintf.c#L60-L63
> (always nul terminates)
> NetBSD: 
> https://github.com/NetBSD/src/blob/trunk/lib/libc/stdio/vsnprintf.c#L97-L101
> (always nul terminates)
> Linux (kernel):
> https://elixir.bootlin.com/linux/latest/source/lib/vsprintf.c#L2645
> (always nul terminates)
> 
> None of these are conditional on error status.
> 
> The only exception I found is musl libc, and in that it is a case you
> cannot encounter here (size > INT_MAX).  Arguably this is a bug in
> musl libc.  I did not dive deeper into musl and determine whether
> other errors were nul terminated or not.
> 
> Conrad
> 
> P.S., It seems dubious to be sending diagnostic formatted error
> messages out across the network.
It was and still is very helpful when debuging interop problems if you only 
have access
to a tracefile and can't change the running code. Like people asking you why is 
your
implementation sending back an ABORT when it sees this packet.

Best regards
Michael
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r361227 - head/sys/netinet

2020-05-18 Thread Michael Tuexen
Author: tuexen
Date: Mon May 18 19:48:38 2020
New Revision: 361227
URL: https://svnweb.freebsd.org/changeset/base/361227

Log:
  Remove assignment without effect.
  
  MFC after:3 days

Modified:
  head/sys/netinet/sctp_auth.c

Modified: head/sys/netinet/sctp_auth.c
==
--- head/sys/netinet/sctp_auth.cMon May 18 19:35:46 2020
(r361226)
+++ head/sys/netinet/sctp_auth.cMon May 18 19:48:38 2020
(r361227)
@@ -658,7 +658,6 @@ sctp_free_hmaclist(sctp_hmaclist_t *list)
 {
if (list != NULL) {
SCTP_FREE(list, SCTP_M_AUTH_HL);
-   list = NULL;
}
 }
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


  1   2   3   4   5   6   7   8   9   10   >