Skip to content

Commit

Permalink
Revert "Improve computation of alternate nets"
Browse files Browse the repository at this point in the history
This reverts commit c75d0cf.
  • Loading branch information
tuexen committed Feb 21, 2021
1 parent c75d0cf commit 1e7a618
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 53 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/build-with-cmake.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Build with CMake

on:
push:
branches: [ master, github-actions ]
pull_request:
branches: [ master ]

jobs:
build:

strategy:
matrix:
platform: [ubuntu-latest, macos-latest, windows-latest]
cmake_build_type: [Debug, RelWithDebInfo]
sctp_invariants: [ON, OFF]
sctp_inet6: [ON, OFF]
sctp_inet: [ON, OFF]
sctp_debug: [ON, OFF]

runs-on: ${{ matrix.platform }}

steps:
- uses: actions/checkout@v2
with:
path: 'usrsctp_source'

- name: Prepare dirs
shell: bash
run: |
mkdir -p cmake_build
mkdir -p cmake_install
- name: Generate CMake project
shell: bash
run: |
cd cmake_build
cmake -DCMAKE_BUILD_TYPE=${{ matrix.cmake_build_type }} \
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON \
-Dsctp_debug=${{ matrix.sctp_debug }} \
-Dsctp_invariants=${{ matrix.sctp_invariants }} \
-Dsctp_inet6=${{ matrix.sctp_inet6 }} \
-Dsctp_inet=${{ matrix.sctp_inet }} \
-Dsctp_build_programs=ON \
-Dsctp_build_fuzzer=OFF \
-DCMAKE_INSTALL_PREFIX=${GITHUB_WORKSPACE}/cmake_install \
${GITHUB_WORKSPACE}/usrsctp_source
- name: Build and install project
shell: bash
run: |
cmake --build cmake_build \
--parallel 2 \
--config ${{ matrix.cmake_build_type }} \
--target install \
--clean-first
2 changes: 1 addition & 1 deletion fuzzer/build-fuzzer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pwd
find . -iwholename '*cmake*' -not -name CMakeLists.txt -delete

# Build with ASAN / MSAN
cmake -Dsctp_build_shared_lib=1 -Dsctp_build_fuzzer=1 -Dsctp_build_programs=0 -Dsctp_invariants=1 -Dsctp_sanitizer_address=1 -DCMAKE_LINKER="$CC" -DCMAKE_C_COMPILER="$CC" .
cmake -Dsctp_build_fuzzer=1 -Dsctp_build_programs=0 -Dsctp_invariants=1 -Dsctp_sanitizer_address=1 -DCMAKE_LINKER="$CC" -DCMAKE_C_COMPILER="$CC" .
#cmake -Dsctp_build_fuzzer=1 -Dsctp_build_programs=0 -Dsctp_invariants=1 -Dsctp_sanitizer_memory=1 -DCMAKE_LINKER="$CC" -DCMAKE_C_COMPILER="$CC" .

make -j"$NPROC"
6 changes: 1 addition & 5 deletions usrsctplib/netinet/sctp_pcb.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

#if defined(__FreeBSD__) && !defined(__Userspace__)
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
__FBSDID("$FreeBSD: head/sys/netinet/sctp_pcb.c 366483 2020-10-06 11:29:08Z tuexen $");
#endif

#include <netinet/sctp_os.h>
Expand Down Expand Up @@ -5181,10 +5181,6 @@ sctp_remove_net(struct sctp_tcb *stcb, struct sctp_nets *net)
/* Clear net */
asoc->last_control_chunk_from = NULL;
}
if (net == asoc->last_net_cmt_send_started) {
/* Clear net */
asoc->last_net_cmt_send_started = NULL;
}
if (net == stcb->asoc.alternate) {
sctp_free_remote_addr(stcb->asoc.alternate);
stcb->asoc.alternate = NULL;
Expand Down
84 changes: 37 additions & 47 deletions usrsctplib/netinet/sctp_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

#if defined(__FreeBSD__) && !defined(__Userspace__)
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
__FBSDID("$FreeBSD: head/sys/netinet/sctp_timer.c 365071 2020-09-01 21:19:14Z mjg $");
#endif

#define _IP_VHL
Expand Down Expand Up @@ -171,8 +171,8 @@ sctp_threshold_management(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
}

/*
* sctp_find_alternate_net() returns a non-NULL pointer as long as there
* exists nets, which are not being deleted.
* sctp_find_alternate_net() returns a non-NULL pointer as long
* the argument net is non-NULL.
*/
struct sctp_nets *
sctp_find_alternate_net(struct sctp_tcb *stcb,
Expand All @@ -181,13 +181,13 @@ sctp_find_alternate_net(struct sctp_tcb *stcb,
{
/* Find and return an alternate network if possible */
struct sctp_nets *alt, *mnet, *min_errors_net = NULL , *max_cwnd_net = NULL;
bool looped;
int once;
/* JRS 5/14/07 - Initialize min_errors to an impossible value. */
int min_errors = -1;
uint32_t max_cwnd = 0;

if (stcb->asoc.numnets == 1) {
/* No selection can be made. */
/* No others but net */
return (TAILQ_FIRST(&stcb->asoc.nets));
}
/*
Expand Down Expand Up @@ -323,22 +323,25 @@ sctp_find_alternate_net(struct sctp_tcb *stcb,
return (max_cwnd_net);
}
}
/* Look for an alternate net, which is active. */
if ((net != NULL) && ((net->dest_state & SCTP_ADDR_BEING_DELETED) == 0)) {
alt = TAILQ_NEXT(net, sctp_next);;
} else {
alt = TAILQ_FIRST(&stcb->asoc.nets);
mnet = net;
once = 0;

if (mnet == NULL) {
mnet = TAILQ_FIRST(&stcb->asoc.nets);
if (mnet == NULL) {
return (NULL);
}
}
looped = false;
for (;;) {
alt = TAILQ_NEXT(mnet, sctp_next);
if (alt == NULL) {
if (!looped) {
alt = TAILQ_FIRST(&stcb->asoc.nets);
looped = true;
once++;
if (once > 1) {
break;
}
/* Definitely out of candidates. */
alt = TAILQ_FIRST(&stcb->asoc.nets);
if (alt == NULL) {
break;
return (NULL);
}
}
#if defined(__FreeBSD__) && !defined(__Userspace__)
Expand All @@ -358,56 +361,43 @@ sctp_find_alternate_net(struct sctp_tcb *stcb,
#else
(alt->ro.ro_rt != NULL) &&
#endif
(!(alt->dest_state & SCTP_ADDR_UNCONFIRMED)) &&
(alt != net)) {
/* Found an alternate net, which is reachable. */
(!(alt->dest_state & SCTP_ADDR_UNCONFIRMED))) {
/* Found a reachable address */
break;
}
alt = TAILQ_NEXT(alt, sctp_next);
mnet = alt;
}

if (alt == NULL) {
/*
* In case no active alternate net has been found, look for
* an alternate net, which is confirmed.
*/
if ((net != NULL) && ((net->dest_state & SCTP_ADDR_BEING_DELETED) == 0)) {
alt = TAILQ_NEXT(net, sctp_next);;
} else {
alt = TAILQ_FIRST(&stcb->asoc.nets);
}
looped = false;
/* Case where NO insv network exists (dormant state) */
/* we rotate destinations */
once = 0;
mnet = net;
for (;;) {
if (mnet == NULL) {
return (TAILQ_FIRST(&stcb->asoc.nets));
}
alt = TAILQ_NEXT(mnet, sctp_next);
if (alt == NULL) {
if (!looped) {
alt = TAILQ_FIRST(&stcb->asoc.nets);
looped = true;
once++;
if (once > 1) {
break;
}
/* Definitely out of candidates. */
alt = TAILQ_FIRST(&stcb->asoc.nets);
if (alt == NULL) {
break;
}
}
if ((!(alt->dest_state & SCTP_ADDR_UNCONFIRMED)) &&
(alt != net)) {
/* Found an alternate net, which is confirmed. */
/* Found an alternate address */
break;
}
alt = TAILQ_NEXT(alt, sctp_next);
mnet = alt;
}
}
if (alt == NULL) {
/*
* In case no confirmed alternate net has been found, just
* return net, if it is not being deleted. In the other case
* just return the first net.
*/
if ((net != NULL) && ((net->dest_state & SCTP_ADDR_BEING_DELETED) == 0)) {
alt = net;
}
if (alt == NULL) {
alt = TAILQ_FIRST(&stcb->asoc.nets);
}
return (net);
}
return (alt);
}
Expand Down

0 comments on commit 1e7a618

Please sign in to comment.