Page MenuHomeFreeBSD

DRAFT: ng_ksocket: IPv6 address parsing and unparsing
Needs ReviewPublic

Authored by nc on Feb 22 2020, 4:23 AM.
Referenced Files
Unknown Object (File)
Wed, May 8, 4:03 PM
Unknown Object (File)
Thu, May 2, 9:48 AM
Unknown Object (File)
Thu, May 2, 9:35 AM
Unknown Object (File)
Thu, May 2, 9:32 AM
Unknown Object (File)
Thu, May 2, 9:32 AM
Unknown Object (File)
Thu, May 2, 9:32 AM
Unknown Object (File)
Thu, May 2, 9:32 AM
Unknown Object (File)
Thu, May 2, 9:32 AM

Details

Reviewers
hrs
Group Reviewers
manpages
Summary

Add IPv6 support to address parsing and unparsing to ng_ksocket.

Submitted by: Neel Chauhan <neel AT neelc DOT org>

Keep in mind that this is a DRAFT. Things still need to be done, including:

  • Fix the "ngctl: send msg: Invalid argument" error - I don't know where this fails or if I am doing something wrong.
  • Anything more commenters want
Test Plan

Do something like this:

  1. ngctl

+ mkpeer ksocket myhook2 inet6/stream/tcp6
+ msg .:myhook2 connect inet6/[::1]:22

The above does not work, see the summary for more details.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

nc retitled this revision from DRAFT: ng_ksocket IPv6 address parsing and unparsing to DRAFT: ng_ksocket: IPv6 address parsing and unparsing.
nc edited the summary of this revision. (Show Details)
nc edited the test plan for this revision. (Show Details)

Remove testing printfs.

hrs requested changes to this revision.Feb 23 2020, 5:23 PM
hrs added a subscriber: hrs.
hrs added inline comments.
sys/netgraph/ng_ksocket.c
328

inet_pton in libkern should be used to parse an IPv6 address. Also, you should consider to support a link-local address with an interface identifier such as [fe80::1%em0]:80.

421

Please use inet_ntop(). And sin6->sin6_scope_id must not be ignored. The in-kernel representation of an link-local address has embedded scope zone id inside the address itself, so you might want to double-check the scope and value of sin6_addr.s6_addr16[1] in both cases of ntop and pton.

This revision now requires changes to proceed.Feb 23 2020, 5:23 PM
nc edited the summary of this revision. (Show Details)
nc edited the test plan for this revision. (Show Details)

Here, I use inet_pton and inet_ntop. I didn't know this was possible in the kernel, so that's why the first revision lacked this.

I still get "ngctl: send msg: Invalid argument" errors with the commands in the Test Plan. Am I doing anything wrong?

nc edited the summary of this revision. (Show Details)
nc marked 2 inline comments as done.Feb 26 2020, 5:29 PM
nc edited the summary of this revision. (Show Details)

Let's include a man page.

bcr added a subscriber: bcr.

OK from manpages.

In D23788#523247, @neel_neelc.org wrote:

I still get "ngctl: send msg: Invalid argument" errors with the commands in the Test Plan. Am I doing anything wrong?

Well, you've added 3 new places that could return EINVAL. Could it be that one of them fires? Of course there are more places in netgraph that can return EINVAL, but first makes sense to isolate that this isn't new code.

I forgot a "return(0)" in the IPv6 unparsing.

This does not solve the "Invalid argument" errors. However, the issue is not with my code. I tried printfs in the same statements as the EINVAL returns and got nothing.

Something else must be causing this in the ng_ksocket or its dependents.