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

Handle RFC 4007: IPv6 zone indices for link-local scoped addresses #76

Open
cfcs opened this issue Oct 2, 2018 · 2 comments
Open

Handle RFC 4007: IPv6 zone indices for link-local scoped addresses #76

cfcs opened this issue Oct 2, 2018 · 2 comments

Comments

@cfcs
Copy link

cfcs commented Oct 2, 2018

Source: https://en.wikipedia.org/wiki/IPv6_address#Scoped_literal_IPv6_addresses

I had a use for this in SSH forwarding, and wondered if the OCaml SSH stack would be able to support this at some point, so I tried:

utop # Ipaddr.V6.of_string "fe80::1234:5678:9012%em0";;
- : Ipaddr.V6.t option = None

Relevant RFC: RFC 4007 section 6

An implementation SHOULD support at least numerical indices that are
non-negative decimal integers as <zone_id>. The default zone index,
which should typically be 0 (see Section 6), is included in the
integers. When <zone_id> is the default, the delimiter characters
"%" and <zone_id> can be omitted. Similarly, if a textual
representation of an IPv6 address is given without a zone index, it
should be interpreted as

%, where
is the default zone index of the scope that has.

So we should support things like fe80::1%0.

RFC 4007 continues:

An implementation MAY support other kinds of non-null strings as
<zone_id>. However, the strings must not conflict with the delimiter
character. The precise format and semantics of additional strings is
implementation dependent.

In Linux and BSD it seems like the IP stacks (or socket libraries or whatever) accept strings to specify the network interface, like %wifi0, or at least provides a way to resolve the numeric ID from the string automatically. This seems more useful than the numerical ID to me, but that is not compatible with Windows (where you would have to look up the interface).

FreeBSD also accepts stuff like fe80::123:4567:8910:1112%lagg0.1181 (for if lagg0 vlan 1181).

(Thanks a lot to @tykling for helping explain the use of % and for providing FreeBSD examples)

  1. I'm not sure what the best way to expose these zone ID hints would be, but for starters I think it would be nice to simply strip trailing %..* and parse the vanilla IPv6 address.

  2. Reading wikipedia, addresses this range should support zone indices:

fe80::/10
  1. Reading RFC 3513 section 2.7 I interpret it to extend to the "transient local" multicast addresses in this range too (please correct me if I got the CIDR prefix wrong):
ff12::/16

Some test cases:

fe80::1ff:fe23:4567:890a%0
fe80::1%em0
fe80::1ff:fe23:4567:890a%123
ff12::ff00:fe23:4567:890a%10
fe80::123:4567:8910:1112%lagg0.1181
cfcs pushed a commit to robur-coop/ocaml-pf that referenced this issue Oct 2, 2018
avsm added a commit to avsm/opam-repository that referenced this issue Dec 13, 2018
CHANGES:

* Add `pp` functions for prettyprinting and deprecate `pp_hum` variants.
  The two functions are currently the same, so porting is just a matter
  of replacing existing uses of `pp_hum` with `pp` (mirage/ocaml-ipaddr#71 @verbosemode)
* Fix deprecation warnings on newer OCaml standard libraries (mirage/ocaml-ipaddr#74 @cfcs).
* Fix `base-unix` depopt to be a real dependency (mirage/ocaml-ipaddr#68 @rgrinberg).
* Fix missing `sexplib` dependency (mirage/ocaml-ipaddr#66 mirage/ocaml-ipaddr#67 @bmillwood).
* Port to Dune from jbuilder and update opam metadata to 2.0 format (mirage/ocaml-ipaddr#76 @avsm).
* Remove unused variable and bindings warnings in the implementation and
  signatures (mirage/ocaml-ipaddr#76 @avsm)
* Fix toplevel handling of the `ipaddr.top` package by linking
  to compiler-libs instead of compiler-libs.toplevel (mirage/ocaml-ipaddr#76 @avsm based on
  fix in mirage/ocaml-uri#130 by @yallop)
* Update Travis to test latest distros by using their aliases (mirage/ocaml-ipaddr#76 @avsm)
* Upgrade opam metadata to the 2.0 format (mirage/ocaml-ipaddr#76 @avsm)
@cfcs
Copy link
Author

cfcs commented Dec 22, 2019

(this was not fixed in 2.9.0 / #13141 , I believe that was a typo in the issue ID there)

@RyanGibb
Copy link
Contributor

It looks like the Unix module doesn't support this either: ocaml/ocaml#6479

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants