Skip to content

OPTE ports for external services connectivity. - #2857

Merged
luqmana merged 18 commits into
mainfrom
luqmana/service-opte-ports
Apr 26, 2023
Merged

luqmana merged 18 commits into
mainfrom
luqmana/service-opte-ports

Conversation

@luqmana

@luqmana luqmana commented Apr 17, 2023 •

Copy link
Copy Markdown
Contributor

Update RSS & Sled Agent to configure and create OPTE ports for Nexus, External DNS and Boundary NTP services. Nexus side DB updates in subsequent PR.

Based on #2856.

@jmpesp

jmpesp commented Apr 18, 2023

Copy link
Copy Markdown
Contributor

FWIW I'm deploying this to the Canada region to test this. Note that I'm still running with an opte that includes oxidecomputer/opte#347 , so that I potentially don't hit the same scenario.

@leftwo leftwo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I got as far as sled-agent/src/rack_setup/plan/service.rs but thought I would send you some questions now and then go back and read the rest.

Comment thread .github/buildomat/jobs/deploy.sh Resolved
Comment thread common/src/address.rs Resolved
Comment thread common/src/api/external/mod.rs Resolved
Comment thread internal-dns/src/names.rs Resolved
Comment thread openapi/nexus-internal.json Resolved
@luqmana
luqmana force-pushed the luqmana/port-refactor branch from f3c673b to 7d7a6de Compare April 19, 2023 07:36
@luqmana
luqmana force-pushed the luqmana/service-opte-ports branch from f755b85 to 8e1433d Compare April 19, 2023 07:37
@luqmana
luqmana force-pushed the luqmana/port-refactor branch from 7d7a6de to cb52630 Compare April 20, 2023 02:24
@luqmana
luqmana force-pushed the luqmana/service-opte-ports branch 3 times, most recently from 6dcf941 to e143db4 Compare April 20, 2023 02:45
@jmpesp

jmpesp commented Apr 20, 2023

Copy link
Copy Markdown
Contributor

FWIW I'm deploying this to the Canada region to test this. Note that I'm still running with an opte that includes oxidecomputer/opte#347 , so that I potentially don't hit the same scenario.

If internal_services_ip_pool_ranges uses V4 addresses, this works perfectly. If it uses V6 addresses, then it does not work. Encapsulated neighbour solicitations reach the sled:

19:29:43.456788 IP6 (hlim 63, next-header UDP (17) payload length: 102) fd03:1122:3344:101::15.42950 > fd00:1122:3344:103::1.6081: [udp sum ok] Geneve, Flags [none], vni 0x64
        IP6 (flowlabel 0xfabf8, hlim 255, next-header ICMPv6 (58) payload length: 32) fe80::d4b3:74ff:fe8a:44a2 > ff02::1:ff00:6: [icmp6 sum ok] ICMP6, neighbor solicitation, length 32, who has fd02:1122:3344:101::6
          source link-address option (1), length 8 (1): d6:b3:74:8a:44:a2
            0x0000:  d6b3 748a 44a2

but not the instance. They're also not responded to by OPTE.

Note: in the above case, the internal services IP pool range is fd02:1122:3344:0101::3 to fd02:1122:3344:0101::FF, the sled's V6 is fd00:1122:3344:103::1, and the boundary services IP is fd03:1122:3344:101::15. fd02:1122:3344:101::6 is the IP that points to a oxz_ntp zone on that sled.

Comment thread illumos-utils/src/running_zone.rs Resolved
@luqmana

luqmana commented Apr 20, 2023

Copy link
Copy Markdown
Contributor Author

FWIW I'm deploying this to the Canada region to test this. Note that I'm still running with an opte that includes oxidecomputer/opte#347 , so that I potentially don't hit the same scenario.

If internal_services_ip_pool_ranges uses V4 addresses, this works perfectly. If it uses V6 addresses, then it does not work. Encapsulated neighbour solicitations reach the sled:

19:29:43.456788 IP6 (hlim 63, next-header UDP (17) payload length: 102) fd03:1122:3344:101::15.42950 > fd00:1122:3344:103::1.6081: [udp sum ok] Geneve, Flags [none], vni 0x64
        IP6 (flowlabel 0xfabf8, hlim 255, next-header ICMPv6 (58) payload length: 32) fe80::d4b3:74ff:fe8a:44a2 > ff02::1:ff00:6: [icmp6 sum ok] ICMP6, neighbor solicitation, length 32, who has fd02:1122:3344:101::6
          source link-address option (1), length 8 (1): d6:b3:74:8a:44:a2
            0x0000:  d6b3 748a 44a2

but not the instance. They're also not responded to by OPTE.

Note: in the above case, the internal services IP pool range is fd02:1122:3344:0101::3 to fd02:1122:3344:0101::FF, the sled's V6 is fd00:1122:3344:103::1, and the boundary services IP is fd03:1122:3344:101::15. fd02:1122:3344:101::6 is the IP that points to a oxz_ntp zone on that sled.

Thanks for testing that out! Glad to see IPv4 is working as expected for not just me 😄️ For the IPv6 stuff, I was hoping it would just work (TM) but alas too much to hope. Given we said IPv6 here wasn't necessary in a network sync like 2 weeks back, I'm inclined to say it's not a blocker for this.

@jmpesp

jmpesp commented Apr 20, 2023

Copy link
Copy Markdown
Contributor

Glad to test :)

I also observed the following (in the opposite direction, the original IPv6 post was about NS from outside in).

The zone does neighbour advertisement over its vopte0:

fe80::aa40:25ff:feff:ea9a -> ff02::1      ICMPv6 Neighbor advertisement
fd77:e9d2:9cd9:2::6 -> ff02::1      ICMPv6 Neighbor advertisement

This leaves the sled (fd00:1122:3344:103::1) GENEVE encapsulated, destined for boundary services (fd03:1122:3344:101::15):

20:27:53.877074 IP6 (hlim 128, next-header UDP (17) payload length: 102) fd00:1122:3344:103::1.7777 > fd03:1122:3344:101::15.6081: [bad udp cksum 0x0000 -> 0x115e!] Geneve, Flags [none], vni 0x63
	IP6 (hlim 255, next-header ICMPv6 (58) payload length: 32) fd02:1122:3344:101::6 > ip6-allnodes: [icmp6 sum ok] ICMP6, neighbor advertisement, length 32, tgt is fd77:e9d2:9cd9:2::6, Flags [override]
	  destination link-address option (2), length 8 (1): a8:40:25:ff:ea:9a
	    0x0000:  a840 25ff ea9a

and (admittedly my Canada region fake) boundary service decaps it:

16:27:52.500968 IP6 (hlim 255, next-header ICMPv6 (58) payload length: 32) fd02:1122:3344:101::6 > ip6-allnodes: [icmp6 sum ok] ICMP6, neighbor advertisement, length 32, tgt is fd77:e9d2:9cd9:2::6, Flags [override]
	  destination link-address option (2), length 8 (1): a8:40:25:ff:ea:9a
	    0x0000:  a840 25ff ea9a

but note the target is fd77:e9d2:9cd9:2::6, not fd02:1122:3344:101::6, which is the vopte1/public, not the external address from the internal services ip pool range. Is OPTE supposed to rewrite this?

If I add fd77:e9d2:9cd9:2::1 as an address of the (again, fake!) boundary services virtual bridge, and ping fd77:e9d2:9cd9:2::6, that does get all the way through to inside the zone:

fd77:e9d2:9cd9:2::1 -> fd77:e9d2:9cd9:2::6 ICMPv6 Echo request (ID: 17758 Sequence number: 1)
fd77:e9d2:9cd9:2::1 -> fd77:e9d2:9cd9:2::6 ICMPv6 Echo request (ID: 17758 Sequence number: 2)
fd77:e9d2:9cd9:2::1 -> fd77:e9d2:9cd9:2::6 ICMPv6 Echo request (ID: 17758 Sequence number: 3)
fd77:e9d2:9cd9:2::1 -> fd77:e9d2:9cd9:2::6 ICMPv6 Echo request (ID: 17758 Sequence number: 4)
fd77:e9d2:9cd9:2::1 -> fd77:e9d2:9cd9:2::6 ICMPv6 Echo request (ID: 17758 Sequence number: 5)
fd77:e9d2:9cd9:2::1 -> fd77:e9d2:9cd9:2::6 ICMPv6 Echo request (ID: 17758 Sequence number: 6)
fd77:e9d2:9cd9:2::1 -> fd77:e9d2:9cd9:2::6 ICMPv6 Echo request (ID: 17758 Sequence number: 7)
fd77:e9d2:9cd9:2::1 -> fd77:e9d2:9cd9:2::6 ICMPv6 Echo request (ID: 17758 Sequence number: 8)
fd77:e9d2:9cd9:2::1 -> fd77:e9d2:9cd9:2::6 ICMPv6 Echo request (ID: 17758 Sequence number: 9)

but the zone doesn't respond. This may be due to its vopte0/public being a /128?

root@oxz_ntp:~# ipadm delete-addr vopte0/public 
root@oxz_ntp:~# ipadm
ADDROBJ           TYPE     STATE        ADDR
lo0/v4            static   ok           127.0.0.1/8
lo0/v6            static   ok           ::1/128
oxControlService0/ll addrconf ok        fe80::8:20ff:fefb:d423/10
oxControlService0/omicron6 static ok    fd00:1122:3344:103::4/64
vopte0/?          dhcp     down         ?
root@oxz_ntp:~# ipadm create-addr -t -T addrconf vopte0/ll
root@oxz_ntp:~# ipadm create-addr -t -T static -a fd77:e9d2:9cd9:2::6/64 vopte0/public
root@oxz_ntp:~# 
root@oxz_ntp:~# ipadm
ADDROBJ           TYPE     STATE        ADDR
lo0/v4            static   ok           127.0.0.1/8
lo0/v6            static   ok           ::1/128
oxControlService0/ll addrconf ok        fe80::8:20ff:fefb:d423/10
oxControlService0/omicron6 static ok    fd00:1122:3344:103::4/64
vopte0/ll         addrconf ok           fe80::aa40:25ff:feff:ea9a/10
vopte0/public     static   ok           fd77:e9d2:9cd9:2::6/64

Nope, still doesn't respond to the ping.

I'm very much at the limit of my (not a lot of) IPv6 knowledge so I'm probably missing something to do with neighbour advertisements and solicitations, but the original zone advertisement being for the zone's internal ipv6 and not the external ipv6 looked off to me.

Base automatically changed from luqmana/port-refactor to main April 20, 2023 22:20
@bnaecker

Copy link
Copy Markdown
Collaborator

I think we probably need to drop most NDP traffic to/from the port. Conceptually, OPTE is supposed to act like the only other link on the local network with the port. There shouldn't be any other neighbors, and nothing should see this port as a neighbor either. That means the "guest" should not see any NAs besides OPTEs, nor should OPTE transit any NSs from the guest (or RSs, though downstream routers are supposed to ignore that if the hop-limit isn't 255).

Right now we're:

  • Hairpinning ICMPv6 echo requests to the gateway
  • Responding to RSs from the guest with RAs from OPTE
  • Responding to NSs from the guest with NAs from OPTE

This may have been missed in the changes that made most layers drop packets with no match by default? I'm not sure. @luqmana thoughts on this?

@luqmana
luqmana force-pushed the luqmana/service-opte-ports branch from e143db4 to 8b7d005 Compare April 20, 2023 23:01
@luqmana

luqmana commented Apr 20, 2023

Copy link
Copy Markdown
Contributor Author

That lines up with my understanding. In a guest or zone with OPTE, other than the "gateway", everything else should be considered off-link. OPTE will handle the NAT-ing between private VPC and external IPs. We also configure the switch with (separate) NAT entries for mapping a given external IP and port range to a specific Sled & VPC [1].

I believe Boundary Services is the one responsible for advertising the external IPs to the broader customer network (unsure of details here). In a local dev context with SoftNPU where we just carve out a portion of the LAN we perform Proxy ARP today (but not for NDP!).

[1] SoftNPU currently silently fails on adding these.

@luqmana

luqmana commented Apr 21, 2023

Copy link
Copy Markdown
Contributor Author

With the tfpkt workaround (see #2903), was able to get this running successfully on the dogfood rack!

@luqmana
luqmana force-pushed the luqmana/service-opte-ports branch from fb21daa to 97e964e Compare April 23, 2023 03:16
Comment thread common/src/address.rs Resolved
Comment thread common/src/address.rs Resolved
Comment thread common/src/address.rs Resolved
Comment thread common/src/address.rs

lazy_static::lazy_static! {
/// The IPv6 prefix assigned to the built-in services VPC.
pub static ref SERVICE_VPC_IPV6_PREFIX: Ipv6Net = Ipv6Net(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This doesn't seem to be used (at least git grep didn't find it).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I have a follow up where the VPC is actually created in DB where it gets used.

Comment thread common/src/address.rs
);

/// The IPv4 subnet for External DNS OPTE portsv
pub static ref DNS_OPTE_IPV4_SUBNET: Ipv4Net =

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

All of these values appear only to be used by the RSS inside sled agent. Could these live there (in sled-agent/src/rack_setup/plan/service.rs), just to scope down the visibility?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I had these in common because I also wanted to use them while actually creating the VPC & subnet DB records in a follow up change.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I wonder if it would make sense to have a crate that both RSS and Nexus use, since it seems like those two will share some infrastructure that we don't need everywhere else. I wouldn't consider this a blocker here, more like something to consider as we keep working on these things.

Comment thread common/src/api/external/mod.rs Resolved
//! Internally facing APIs.

pub mod nexus;
pub mod shared;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think we've been trying to move away from sharing types between client and server in a big "common" package and instead using progenitor-generated types (where that makes sense).

I see these types used to be in illumos-utils, and that makes sense to me. Why move them?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

my local branch uses these types in nexus as well in the nexus handoff to add the corresponding service vnic DB records. So both nexus and sled-agent would then have APIs using these types which I want to stay in-sync.

Comment thread common/src/api/internal/shared.rs Resolved
Comment thread illumos-utils/src/zone.rs
})?;
Ok(String::from_utf8_lossy(&output.stdout)
.lines()
.filter_map(|s| s.parse().ok())

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Do we expect all of these to parse successfully? Or: is there any reason not to record or report some kind of error if one fails?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This was mostly cribbed from get_address above but yea, as the output of ipadm show-addr -p -o ADDR all of em should parse.

) -> Result<(), SetupServiceError> {
let log = &self.log;
// Start up the internal DNS services
futures::future::join_all(service_plan.services.iter().map(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I thought this code must have moved but I don't see from where. How was this working before?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This method (initialize_dns) was previously called after both the Internal DNS and NTP services were initialized. But I needed DNS while initializing NTP (to lookup dendrite via internal DNS when creating NAT entry) so this method got moved up and also takes care to initialize any internal DNS zones.

@davepacheco

Copy link
Copy Markdown
Collaborator

I took a pass through most of the non-OPTE parts here. It'll take some more time to go through the OPTE parts (if that's useful). I'm much less familiar with that. (As it is, a bunch of this is new to me, so sorry for any ignorant questions!)

@luqmana
luqmana force-pushed the luqmana/service-opte-ports branch from 2df972f to 39e488c Compare April 25, 2023 19:51

@smklein smklein left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good to me, especially as this unblocks dogfood. I think there are some follow-ups we can take, and I marked spots where I think it would be nice to have tracking issues, but I don't think they need to block this PR.

Nice work getting this together, integrating this many pieces is a really impressive feat.

Comment thread illumos-utils/src/opte/port_manager.rs Resolved
Comment thread illumos-utils/src/running_zone.rs Resolved
Comment thread illumos-utils/src/running_zone.rs Resolved
Comment thread illumos-utils/src/running_zone.rs Resolved
Comment on lines +701 to +726
dpd_client
.nat_ipv4_create(
ip,
first_port,
last_port,
&nat_target,
)
.await
}
IpAddr::V6(ip) => {
dpd_client
.nat_ipv6_create(
ip,
first_port,
last_port,
&nat_target,
)
.await

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We discussed this a little bit offline, but since calls to dendrite are stateful, we may want to consider placing these in a saga.

There is definitely a chicken-and-egg problem here -- on reboot:

  • sled agent needs to be able to program dendrite to give NTP access to external servers...
  • ... which is needed to start CRDB
  • ... which is needed to start Nexus, which can run other sagas

That specific scenario aside, there may be value in making these calls from a saga, where they can be rolled back on failure. As implemented, if we fail part-way through the for svc in &req.services loop, we'll simply leak these resources.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

(In the interest of time, we can totally punt this to a follow-up PR, but we should track this improvement somehow)

@luqmana
luqmana force-pushed the luqmana/service-opte-ports branch from 39e488c to 9e4179d Compare April 26, 2023 20:40
@luqmana
luqmana merged commit 73ca09a into main Apr 26, 2023
@luqmana
luqmana deleted the luqmana/service-opte-ports branch April 26, 2023 22:05
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

Successfully merging this pull request may close these issues.

6 participants