Skip to content

gcoap_forward_proxy: provide cache validation mechanism #17801

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 12, 2022

Conversation

miri64
Copy link
Member

@miri64 miri64 commented Mar 11, 2022

Contribution description

This provides support for the cache validation mechanism of CoAP for the gcoap_forward_proxy module if nanocoap_cache is also provided.

Testing procedure

TBD procedurally, but could be easily done with an aiocoap server with ETag support, a RIOT client and a RIOT forward proxy inbetween the two. The client requests a resource via the proxy (the server delivers the data with an ETag), waits until the Max-Age (default 60 seconds) of the resource passed, then requests the (assumed to be unchanging) resource again. This should trigger the proxy to send a request with the resource's ETag to the server which in turn answers with a 2.03 Valid response. The proxy should then send the original cached response back (and update the cache entries Max-Age).

Issues/PRs references

Requires #13889 and its dependencies.

@github-actions github-actions bot added Area: build system Area: Build system Area: CoAP Area: Constrained Application Protocol implementations Area: Kconfig Area: Kconfig integration Area: network Area: Networking Area: sys Area: System Area: tests Area: tests and testing framework labels Mar 11, 2022
@miri64 miri64 changed the title Gcoap forward proxy/enh/etag gcoap_forward_proxy: provide cache validation mechanism Mar 11, 2022
@miri64 miri64 added Type: new feature The issue requests / The PR implemements a new feature for RIOT State: waiting for other PR State: The PR requires another PR to be merged first labels Mar 11, 2022
@miri64 miri64 force-pushed the gcoap_forward_proxy/enh/etag branch from bde1484 to 10d24b4 Compare March 11, 2022 15:33
@miri64 miri64 force-pushed the gcoap_forward_proxy/enh/etag branch from 10d24b4 to 21fbacc Compare March 15, 2022 20:09
@github-actions github-actions bot removed the Area: build system Area: Build system label Mar 15, 2022
@miri64 miri64 force-pushed the gcoap_forward_proxy/enh/etag branch from 21fbacc to 1435718 Compare March 15, 2022 20:21
@miri64 miri64 force-pushed the gcoap_forward_proxy/enh/etag branch 2 times, most recently from ce54fdc to ecabce6 Compare March 29, 2022 16:06
@miri64 miri64 force-pushed the gcoap_forward_proxy/enh/etag branch from ecabce6 to 24472a8 Compare May 11, 2022 09:30
@github-actions github-actions bot removed Area: tests Area: tests and testing framework Area: Kconfig Area: Kconfig integration labels May 11, 2022
@miri64
Copy link
Member Author

miri64 commented May 11, 2022

Rebased and retested on native with the testing procedures (I patched aiocoap's fileserver to speed up the testing a bit:

diff --git a/aiocoap/cli/fileserver.py b/aiocoap/cli/fileserver.py
index 1bf2ba4..f6ce129 100644
--- a/aiocoap/cli/fileserver.py
+++ b/aiocoap/cli/fileserver.py
@@ -160,2 +160,3 @@ class FileServer(Resource, aiocoap.interfaces.ObservableResource):
 
+        response.opt.max_age = 10
         response.opt.etag = etag

)

$ sudo ./dist/tool/tapsetup/tapsetup
$ PORT=tap1 USEMODULE="gcoap_forward_proxy nanocoap_cache" make -C examples/gcoap -j flash term
...
[second terminal in aiocoap repo]
$ ./aiocoap-fileserver --bind "[$(ip addr show dev tapbr0 scope link | grep -o 'inet6 [0-9a-f:]\+' | sed 's/inet6 //')%tapbr0]" test/
...
[third terminal]
$ make -C examples/gcoap term
All up, running the shell now
> coap proxy set fe80::e0bc:7dff:fecb:f550 5683
coap proxy set fe80::e0bc:7dff:fecb:f550 5683
> 

> coap get fe80::dc1a:a8ff:fe09:45b3 5683 /a.txt
coap get fe80::dc1a:a8ff:fe09:45b3 5683 /a.txt
gcoap_cli: sending msg ID 51017, 54 bytes
> --- blockwise start ---
gcoap: response Success, code 2.05, 7 bytes
foobar

--- blockwise complete ---
coap get fe80::dc1a:a8ff:fe09:45b3 5683 /a.txt
coap get fe80::dc1a:a8ff:fe09:45b3 5683 /a.txt
gcoap_cli: sending msg ID 51018, 54 bytes
> --- blockwise start ---
gcoap: response Success, code 2.05, 7 bytes
foobar

--- blockwise complete ---


^C
native: exiting

image

@miri64 miri64 force-pushed the gcoap_forward_proxy/enh/etag branch from 24472a8 to 1b569a5 Compare May 11, 2022 09:45
@github-actions github-actions bot added the Area: tools Area: Supplementary tools label May 11, 2022
@miri64 miri64 removed the State: waiting for other PR State: The PR requires another PR to be merged first label May 11, 2022
@miri64 miri64 added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label May 11, 2022
@miri64
Copy link
Member Author

miri64 commented May 11, 2022

Addressed doxygen errors and squashed.

Copy link
Member

@cgundogan cgundogan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few nits.

@github-actions github-actions bot added Area: examples Area: Example Applications and removed Area: examples Area: Example Applications labels May 11, 2022
@miri64 miri64 force-pushed the gcoap_forward_proxy/enh/etag branch from ccd7dff to 9d4bb84 Compare May 11, 2022 15:38
@miri64
Copy link
Member Author

miri64 commented May 11, 2022

Squashed as requested off-line

@cgundogan
Copy link
Member

I tested more extensively today and found a strange error path:
After a second validation (so waiting again at least Max-Age seconds), requests seem to return an internal server error. Have a look at the attached wireshark capture and the Time column.

image

@miri64
Copy link
Member Author

miri64 commented May 12, 2022

Mh... that indicates, that the proxy is not able to allocate another cep. Will have a look.

@miri64
Copy link
Member Author

miri64 commented May 12, 2022

fb9a11d fixes that. On validation, the client ep was previously not freed correctly 😅. Good catch!

@cgundogan
Copy link
Member

Alright, I can't reproduce this error anymore with your fix. Looks good! Please squash.

@miri64 miri64 force-pushed the gcoap_forward_proxy/enh/etag branch from fb9a11d to 73bcd83 Compare May 12, 2022 11:22
Copy link
Member

@cgundogan cgundogan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK

@cgundogan cgundogan added Reviewed: 1-fundamentals The fundamentals of the PR were reviewed according to the maintainer guidelines Reviewed: 2-code-design The code design of the PR was reviewed according to the maintainer guidelines Reviewed: 3-testing The PR was tested according to the maintainer guidelines labels May 12, 2022
@cgundogan cgundogan enabled auto-merge May 12, 2022 11:25
@cgundogan cgundogan merged commit 820ca61 into RIOT-OS:master May 12, 2022
@miri64 miri64 deleted the gcoap_forward_proxy/enh/etag branch May 12, 2022 15:35
@miri64 miri64 mentioned this pull request May 16, 2022
@chrysn chrysn added this to the Release 2022.07 milestone Aug 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: CoAP Area: Constrained Application Protocol implementations Area: network Area: Networking Area: sys Area: System Area: tools Area: Supplementary tools CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Reviewed: 1-fundamentals The fundamentals of the PR were reviewed according to the maintainer guidelines Reviewed: 2-code-design The code design of the PR was reviewed according to the maintainer guidelines Reviewed: 3-testing The PR was tested according to the maintainer guidelines Type: new feature The issue requests / The PR implemements a new feature for RIOT
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants