Skip to content
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

Option to handle DNS requesets by lwIP #74

Merged
merged 3 commits into from Feb 9, 2024

Conversation

skuenzer
Copy link
Member

@skuenzer skuenzer commented Feb 6, 2024

This PR introduces an option to use lwIP's DNS resolution for getaddrinfo(), getnameinfo(), gethostbyname(), and family. It can be enabled if lwIP is available. It will enable lwIP's DNS and socket interfaces.
The advantages of this implementation is that

  1. there needs to place an /etc/resolv.conf in the VFS,
  2. Works with DNS servers that lwIP got assigned with a DHCP reply.

This PR depends on PR #48 for lib/lwip.

This commit introduces an option to use lwIP's implementation of getaddrinfo.
It can be enabled if lwip is available. It will enable lwIP's DNS and socket
interfaces.

Signed-off-by: Simon Kuenzer <simon@unikraft.io>
This commit copies the lwip glue code for `getnameinfo()` from `lib/newlib`
(unikraft/lib-newlib@727d5ea,
 Commit 727d5ea) to musl. It is only enabled if musl is configured to
forward DNS related requests to lwIP.

Signed-off-by: Simon Kuenzer <simon@unikraft.io>
This commit introduces redirecting `gethostbyname()` (and family) calls
to lwIP's implementation. This is only enabled if musl is configured to
forward DNS related requests to lwIP.

Signed-off-by: Simon Kuenzer <simon@unikraft.io>
@razvand razvand self-assigned this Feb 6, 2024
@razvand razvand added the enhancement New feature or request label Feb 6, 2024
Copy link
Member

@StefanJum StefanJum left a comment

Choose a reason for hiding this comment

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

@skuenzer I get some redefinition errors when building, am I missing something in the config step?

In file included from /media/stefan/projects/unikraft/maintainer-tools/workdir/libs/musl/lwip/gethostbyname.c:9:
/media/stefan/projects/unikraft/maintainer-tools/workdir/apps/nginx/workdir/build/liblwip/origin/fork-lwip-UNIKRAFT-2_1_x/src/include/lwip/netdb.h:92:8: error: redefinition of ‘struct hostent’
   92 | struct hostent {
      |        ^~~~~~~
In file included from /media/stefan/projects/unikraft/maintainer-tools/workdir/libs/musl/lwip/gethostbyname.c:8:
/media/stefan/projects/unikraft/maintainer-tools/workdir/apps/nginx/workdir/build/libmusl/include/network/include/netdb.h:69:8: note: originally defined here
   69 | struct hostent {
      |        ^~~~~~~
In file included from /media/stefan/projects/unikraft/maintainer-tools/workdir/libs/musl/lwip/gethostbyname.c:9:
/media/stefan/projects/unikraft/maintainer-tools/workdir/apps/nginx/workdir/build/liblwip/origin/fork-lwip-UNIKRAFT-2_1_x/src/include/lwip/netdb.h:103:8: error: redefinition of ‘struct addrinfo’
  103 | struct addrinfo {
      |        ^~~~~~~~
In file included from /media/stefan/projects/unikraft/maintainer-tools/workdir/libs/musl/lwip/gethostbyname.c:8:
/media/stefan/projects/unikraft/maintainer-tools/workdir/apps/nginx/workdir/build/libmusl/include/network/include/netdb.h:16:8: note: originally defined here
   16 | struct addrinfo {
      |        ^~~~~~~~
/media/stefan/projects/unikraft/maintainer-tools/workdir/libs/musl/lwip/gethostbyname.c:13:17: error: conflicting types for ‘gethostbyname’; have ‘struct hostent *(const char *)’
   13 | struct hostent *gethostbyname(const char *name) {
      |                 ^~~~~~~~~~~~~
In file included from /media/stefan/projects/unikraft/maintainer-tools/workdir/libs/musl/lwip/gethostbyname.c:8:
/media/stefan/projects/unikraft/maintainer-tools/workdir/apps/nginx/workdir/build/libmusl/include/network/include/netdb.h:116:17: note: previous declaration of ‘gethostbyname’ with type ‘struct hostent *(const ’
  116 | struct hostent *gethostbyname (const char *);
      |                 ^~~~~~~~~~~~~
/media/stefan/projects/unikraft/maintainer-tools/workdir/libs/musl/lwip/gethostbyname.c:17:17: error: conflicting types for ‘gethostbyname2’; have ‘struct hostent *(const char *, int)’
   17 | struct hostent *gethostbyname2(const char *name __unused, int af __unused) {
      |                 ^~~~~~~~~~~~~~
In file included from /media/stefan/projects/unikraft/maintainer-tools/workdir/libs/musl/lwip/gethostbyname.c:8:
/media/stefan/projects/unikraft/maintainer-tools/workdir/apps/nginx/workdir/build/libmusl/include/network/include/netdb.h:135:17: note: previous declaration of ‘gethostbyname2’ with type ‘struct hostent *(const’
  135 | struct hostent *gethostbyname2(const char *, int);
      |                 ^~~~~~~~~~~~~~
/media/stefan/projects/unikraft/maintainer-tools/workdir/libs/musl/lwip/gethostbyname.c:27:5: error: conflicting types for ‘gethostbyname_r’; have ‘int(const char *, struct hostent *, char *, size_t,  struct ho}
   27 | int gethostbyname_r(const char *name, struct hostent *ret, char *buf,
      |     ^~~~~~~~~~~~~~~
In file included from /media/stefan/projects/unikraft/maintainer-tools/workdir/libs/musl/lwip/gethostbyname.c:8:
/media/stefan/projects/unikraft/maintainer-tools/workdir/apps/nginx/workdir/build/libmusl/include/network/include/netdb.h:133:5: note: previous declaration of ‘gethostbyname_r’ with type ‘int(const char *, stru}
  133 | int gethostbyname_r(const char *, struct hostent *, char *, size_t, struct hostent **, int *);
      |     ^~~~~~~~~~~~~~~
/media/stefan/projects/unikraft/maintainer-tools/workdir/libs/musl/lwip/gethostbyname.c:33:5: error: conflicting types for ‘gethostbyname2_r’; have ‘int(const char *, int,  struct hostent *, char *, size_t,  st}
   33 | int gethostbyname2_r(const char *name __unused, int af __unused,
      |     ^~~~~~~~~~~~~~~~
In file included from /media/stefan/projects/unikraft/maintainer-tools/workdir/libs/musl/lwip/gethostbyname.c:8:
/media/stefan/projects/unikraft/maintainer-tools/workdir/apps/nginx/workdir/build/libmusl/include/network/include/netdb.h:134:5: note: previous declaration of ‘gethostbyname2_r’ with type ‘int(const char *, int}
  134 | int gethostbyname2_r(const char *, int, struct hostent *, char *, size_t, struct hostent **, int *);

@skuenzer
Copy link
Member Author

skuenzer commented Feb 6, 2024

Ouh sorry, you need to have the following lwip PR also applied. I forgot to mention that dependency in the description: unikraft/lib-lwip#48

Copy link
Member

@StefanJum StefanJum left a comment

Choose a reason for hiding this comment

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

All good now, thanks.
Reviewed-by: Stefan Jumarea stefanjumarea02@gmail.com

Copy link
Member

@Mihnea0Firoiu Mihnea0Firoiu left a comment

Choose a reason for hiding this comment

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

All good.
Reviewed-by: Mihnea Firoiu mihneafiroiu0@gmail.com

Copy link
Contributor

@razvand razvand left a comment

Choose a reason for hiding this comment

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

Reviewed-by: Razvan Deaconescu razvand@unikraft.io
Approved-by: Razvan Deaconescu razvand@unikraft.io

@razvand razvand added this to the v0.17.0 (Calypso) milestone Feb 9, 2024
@razvand razvand changed the base branch from staging to staging-74 February 9, 2024 20:32
@razvand razvand merged commit bf5acb1 into unikraft:staging-74 Feb 9, 2024
razvand pushed a commit that referenced this pull request Feb 9, 2024
This commit introduces an option to use lwIP's implementation of getaddrinfo.
It can be enabled if lwip is available. It will enable lwIP's DNS and socket
interfaces.

Signed-off-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com>
Reviewed-by: Mihnea Firoiu <mihneafiroiu0@gmail.com>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #74
razvand pushed a commit that referenced this pull request Feb 9, 2024
This commit copies the lwip glue code for `getnameinfo()` from `lib/newlib`
(unikraft/lib-newlib@727d5ea,
 Commit 727d5ea) to musl. It is only enabled if musl is configured to
forward DNS related requests to lwIP.

Signed-off-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com>
Reviewed-by: Mihnea Firoiu <mihneafiroiu0@gmail.com>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #74
razvand pushed a commit that referenced this pull request Feb 9, 2024
This commit introduces redirecting `gethostbyname()` (and family) calls
to lwIP's implementation. This is only enabled if musl is configured to
forward DNS related requests to lwIP.

Signed-off-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com>
Reviewed-by: Mihnea Firoiu <mihneafiroiu0@gmail.com>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #74
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Development

Successfully merging this pull request may close these issues.

None yet

4 participants