Skip to content

Commit f208518

Browse files
tony-josi-awsHolden
authored andcommitted
[IPv6] Verify options order in IPv6 Extension Headers (#802)
* Fix test 1 and 2 of the IPv6 destination opts protocol tests * fixing spelling * uncrustify yml fix (#815) * fix uncrustify run command * fix formatting
1 parent c0f420d commit f208518

File tree

4 files changed

+23
-10
lines changed

4 files changed

+23
-10
lines changed

.github/lexicon.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1738,6 +1738,7 @@ xcolon
17381738
xconnected
17391739
xcount
17401740
xcurlength
1741+
xcurrentorder
17411742
xcurstart
17421743
xdatalength
17431744
xdatalengthbytes
@@ -1781,6 +1782,7 @@ xeventgroupwaitbits
17811782
xexpected
17821783
xexpectedmessagetype
17831784
xexpiredstate
1785+
xextheadercount
17841786
xfamily
17851787
xfield
17861788
xflags

.github/workflows/ci.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,12 @@ jobs:
7171
formatting:
7272
# Use only 18.04 since we want the uncrustify version to
7373
# be 0.66.1_f to ensure proper formatting.
74-
runs-on: ubuntu-18.04
74+
runs-on: ubuntu-20.04
75+
container: ubuntu:18.04
7576
steps:
76-
- uses: actions/checkout@v2
77+
- uses: actions/checkout@v3
7778
- name: Install Uncrustify
78-
run: sudo apt-get install uncrustify
79+
run: apt-get update && apt-get install uncrustify
7980
- name: Run Uncrustify
8081
run: |
8182
uncrustify --version

.github/workflows/uncrustify.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ jobs:
88
Uncrustify:
99
name: Run_Uncrustify
1010
if: ${{ github.event.issue.pull_request && github.event.comment.body == '/bot run uncrustify' }}
11-
runs-on: ubuntu-18.04
11+
runs-on: ubuntu-20.04
12+
container: ubuntu:18.04
1213
steps:
1314
- name: Dump GitHub context
1415
env:
@@ -29,17 +30,16 @@ jobs:
2930
run: |
3031
echo ${{ steps.upstreamrepo.outputs.RemoteRepo }}:${{ steps.upstreambranch.outputs.branchname }}
3132
- name: Checkout upstream repo
32-
uses: actions/checkout@v2
33+
uses: actions/checkout@v3
3334
with:
3435
repository: ${{ steps.upstreamrepo.outputs.RemoteRepo }}
3536
ref: ${{ steps.upstreambranch.outputs.branchname }}
36-
- name: Install Uncrustify
37-
run: sudo apt-get install uncrustify
37+
- name: Install Uncrustify and Git
38+
run: apt-get update && apt-get install uncrustify git-all
3839
- name: Run Uncrustify
3940
run: |
4041
uncrustify --version
4142
find . -iname "*.[hc]" -exec uncrustify -c tools/uncrustify.cfg --no-backup --replace {} +
42-
find . -iname "*.[hc]" -exec uncrustify -c tools/uncrustify.cfg --no-backup --replace {} +
4343
- name: Push changes to upstream repository
4444
run: |
4545
git config --global user.name 'GitHub Action'

source/FreeRTOS_IPv6.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,7 @@ eFrameProcessingResult_t eHandleIPv6ExtensionHeaders( NetworkBufferDescriptor_t
342342
uint8_t ucCurrentHeader = pxIPPacket_IPv6->xIPHeader.ucNextHeader;
343343
uint8_t ucNextHeader = 0U;
344344
BaseType_t xNextOrder = 0;
345+
BaseType_t xExtHeaderCount = 0;
345346

346347
while( ( uxIndex + 8U ) < uxMaxLength )
347348
{
@@ -379,9 +380,18 @@ eFrameProcessingResult_t eHandleIPv6ExtensionHeaders( NetworkBufferDescriptor_t
379380
ucNextHeader,
380381
( int ) xNextOrder ) );
381382

382-
if( xNextOrder <= xCurrentOrder )
383+
xExtHeaderCount += 1;
384+
385+
/*
386+
* IPv6 nodes must accept and attempt to process extension headers in
387+
* any order and occurring any number of times in the same packet,
388+
* except for the Hop-by-Hop Options header which is restricted to
389+
* appear immediately after an IPv6 header only. Outlined
390+
* by RFC 2460 section 4.1 Extension Header Order.
391+
*/
392+
if( ( xExtHeaderCount > 1 ) && ( xCurrentOrder == 1 ) ) /* ipIPv6_EXT_HEADER_HOP_BY_HOP */
383393
{
384-
FreeRTOS_printf( ( "Wrong order\n" ) );
394+
FreeRTOS_printf( ( "Wrong order. Hop-by-Hop Options header restricted to appear immediately after an IPv6 header\n" ) );
385395
uxIndex = uxMaxLength;
386396
break;
387397
}

0 commit comments

Comments
 (0)