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

T160: nat64: prototype #1408

Closed
wants to merge 2 commits into from
Closed

T160: nat64: prototype #1408

wants to merge 2 commits into from

Conversation

vfreex
Copy link
Contributor

@vfreex vfreex commented Jul 11, 2022

Use tayga to do NAT64 translation.

Example usage:

# Stateful NAT64
set interfaces nat64 nat64eth0 ipv4-address '192.168.64.1'
set interfaces nat64 nat64eth0 ipv6-address '2001:db8::1'
set interfaces nat64 nat64eth0 stateful ipv4-pool '192.168.64.0/24'
set interfaces nat64 nat64eth0 stateful prefix '2001:db8:64::/96'
commit
set protocols static route 192.168.64.0/24 interface nat64eth0
set protocols static route6 2001:db8:64::/96 interface nat64eth0
commit

ping6 2001:db8:64::8.8.8.8
PING 2001:db8:64::8.8.8.8(2001:db8:64::808:808) 56 data bytes
64 bytes from 2001:db8:64::808:808: icmp_seq=1 ttl=113 time=46.5 ms
64 bytes from 2001:db8:64::808:808: icmp_seq=2 ttl=113 time=47.1 ms
64 bytes from 2001:db8:64::808:808: icmp_seq=3 ttl=113 time=46.7 ms
64 bytes from 2001:db8:64::808:808: icmp_seq=4 ttl=113 time=47.0 ms
^C
--- 2001:db8:64::8.8.8.8 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 8ms
rtt min/avg/max/mdev = 46.518/46.836/47.138/0.290 ms


# static 1-1 mappings
set interfaces nat64 nat64eth0 host-mapping ipv6 2001:db8:1000::100 ipv4 192.168.64.100
set interfaces nat64 nat64eth0 host-mapping ipv6 2001:db8:1000::101 ipv4 192.168.64.101

Change Summary

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes)
  • Migration from an old Vyatta component to vyos-1x, please link to related PR inside obsoleted component
  • Other (please describe):

Related Task(s)

Component(s) name

Proposed changes

How to test

Checklist:

  • I have read the CONTRIBUTING document
  • I have linked this PR to one or more Phabricator Task(s)
  • I have run the components SMOKETESTS if applicable
  • My commit headlines contain a valid Task id
  • My change requires a change to the documentation
  • I have updated the documentation accordingly

@vfreex
Copy link
Contributor Author

vfreex commented Jul 11, 2022

This is just a prototype to explore how to integrate tayga into VyOS.

data/templates/tayga/tayga.conf.j2 Outdated Show resolved Hide resolved
data/templates/tayga/tayga.conf.j2 Outdated Show resolved Hide resolved
#
# Optional.
#
{% if stateful.ipv4_pool is defined %}
Copy link
Member

Choose a reason for hiding this comment

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

please use vyos_defined

src/conf_mode/interfaces-nat64.py Outdated Show resolved Hide resolved
@@ -0,0 +1,88 @@
#!/usr/bin/env python3
#
# Copyright (C) 2019-2021 VyOS maintainers and contributors
Copy link
Member

Choose a reason for hiding this comment

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

Can be 2022 ;)

# bail out early
return None

verify_vrf(nat64)
Copy link
Member

Choose a reason for hiding this comment

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

I see no use of a VRF - I guess its a copy/paste issue ...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Besides VRF, I also copy-pasted other common config options like netns, mtu, mirror, redirect. I assume those options will be honored by the base class method Interface.update. However I didn't test them. If my assumption is wrong, I can remove them.

Copy link
Member

Choose a reason for hiding this comment

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

Well we should start low and not asume VRF works out of the box. It needs to be tested and could be added later on. In general I like the idea of a per VRF nat64 gateway - but we need to check if the daemon supports it. Please drop:

  • netns
  • mirror
  • redirect

@vfreex vfreex force-pushed the add-nat64 branch 3 times, most recently from fab60f8 to d7df919 Compare July 12, 2022 20:40
Use [tayga][1] to do NAT64 translation.

Example usage:

```
set interfaces nat64 nat64eth0 ipv4-address '192.168.64.1'
set interfaces nat64 nat64eth0 ipv6-address '2001:db8::1'
set interfaces nat64 nat64eth0 stateful ipv4-pool '192.168.64.0/24'
set interfaces nat64 nat64eth0 stateful prefix '2001:db8:64::/96'
commit
set protocols static route 192.168.64.0/24 interface nat64eth0
set protocols static route6 2001:db8:64::/96 interface nat64eth0
commit

ping6 2001:db8:64::8.8.8.8
PING 2001:db8:64::8.8.8.8(2001:db8:64::808:808) 56 data bytes
64 bytes from 2001:db8:64::808:808: icmp_seq=1 ttl=113 time=46.5 ms
64 bytes from 2001:db8:64::808:808: icmp_seq=2 ttl=113 time=47.1 ms
64 bytes from 2001:db8:64::808:808: icmp_seq=3 ttl=113 time=46.7 ms
64 bytes from 2001:db8:64::808:808: icmp_seq=4 ttl=113 time=47.0 ms
^C
--- 2001:db8:64::8.8.8.8 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 8ms
rtt min/avg/max/mdev = 46.518/46.836/47.138/0.290 ms

set interfaces nat64 nat64eth0 host-mapping ipv6 2001:db8:1000::100 ipv4 192.168.64.100
set interfaces nat64 nat64eth0 host-mapping ipv6 2001:db8:1000::101 ipv4 192.168.64.101
commit
```

[1]: http://www.litech.org/tayga/
@vfreex
Copy link
Contributor Author

vfreex commented Jul 22, 2022

Fixed MTU check.

@jack9603301
Copy link
Contributor

Are you going to implement NAT64? This is a nice feature!

@vfreex
Copy link
Contributor Author

vfreex commented Aug 9, 2022

@jack9603301 Hi, this is just a prototype PR to show how to implement NAT64 with tayga. I just tested the basic functionalities of NAT64 for this PR. It would be nice if someone can take over this work and get it into vyos.

Also as I posted in https://phabricator.vyos.net/T160, I know a lot of people want Jool because of its performance. However it would require a much larger effort to integrate and I am not sure how to get the firewall integrated correctly with Jool either. Another concern is that an out-of-tree kernel module could be hard to maintenance in the long term, unless it gets merged into upstream kernel.

So my take is:

  • If someone can get NAT64 implemented with Jool, go for it.
  • Otherwise, tayga sounds like something we can have NOW.

Another high performance option is using VPP. I don't know if vyos has a plan to integrate VPP, but I do have some thoughts and a working demo to show how to integrate it.

@andamasov andamasov requested a review from c-po August 30, 2022 20:02
# bail out early
return None

verify_vrf(nat64)
Copy link
Member

Choose a reason for hiding this comment

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

Well we should start low and not asume VRF works out of the box. It needs to be tested and could be added later on. In general I like the idea of a per VRF nat64 gateway - but we need to check if the daemon supports it. Please drop:

  • netns
  • mirror
  • redirect

shutil.rmtree(configd, ignore_errors=True)
return None

call(f'systemctl restart tayga@{ifname}.service')
Copy link
Member

Choose a reason for hiding this comment

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

Please use reload-or-restart instead. Even it reload is yet not supported we should stick to a pattern if possible.

src/etc/systemd/system/tayga@.service Show resolved Hide resolved
<help>Description</help>
</properties>
</leafNode>
<leafNode name="disable">
Copy link
Member

Choose a reason for hiding this comment

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

Please use #include <include/generic-disable-node.xml.i> instead

</constraint>
</properties>
<children>
<leafNode name="description">
Copy link
Member

Choose a reason for hiding this comment

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

Please use #include <include/generic-description.xml.i>

@c-po c-po requested a review from sever-sever August 31, 2022 17:08
@jack9603301
Copy link
Contributor

jack9603301 commented Aug 31, 2022

@jack9603301 Hi, this is just a prototype PR to show how to implement NAT64 with tayga. I just tested the basic functionalities of NAT64 for this PR. It would be nice if someone can take over this work and get it into vyos.

Also as I posted in https://phabricator.vyos.net/T160, I know a lot of people want Jool because of its performance. However it would require a much larger effort to integrate and I am not sure how to get the firewall integrated correctly with Jool either. Another concern is that an out-of-tree kernel module could be hard to maintenance in the long term, unless it gets merged into upstream kernel.

So my take is:

* If someone can get NAT64 implemented with Jool, go for it.

* Otherwise, tayga sounds like something we can have NOW.

Another high performance option is using VPP. I don't know if vyos has a plan to integrate VPP, but I do have some thoughts and a working demo to show how to integrate it.

I think now may be an opportunity. I found the following link:

Now there is no difficulty in maintaining its kernel module, it seems that debian has helped us maintain it

Maybe we need a little experimentation to make sure it works

But that means vyos needs to maintain each version of jool-dkms by itself

Also about VPP, I don't think vyos should and won't use VPP because VPP depends on DPDK

config_file = f'/run/tayga/{self.ifname}.conf'
call(f"tayga -c {config_file} --mktun")

def update(self, config):
Copy link
Member

Choose a reason for hiding this comment

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

This is not required as the base class handles it all.

@vfreex
Copy link
Contributor Author

vfreex commented Sep 17, 2022

Thanks for the review and suggestions. I have updated the PR to address all the issues.

@jack9603301 Re JOOL, I would like to see a prototype in a separate PR. I may have a look at it as well if I have enough time.

@github-actions
Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@sever-sever sever-sever removed the request for review from DmitriyEshenko March 13, 2023 10:17
@sever-sever sever-sever requested a review from c-po March 13, 2023 10:17
@sever-sever
Copy link
Member

@vfreex could you resolve conflicts?

@vfreex
Copy link
Contributor Author

vfreex commented Jun 29, 2023

@sever-sever This PR means to be a demo and I don't think it is going to be merged as is. I will probably won't keep this PR up to date unless I see people are agreed to implement it this way.

@c-po c-po added the current label Aug 25, 2023
@dmbaturin
Copy link
Member

TAYGA hasn't been updated since 2011 and since it's a userspace implementation, it's going to be a huge performance concern. We will look into adding nftables support to Jool instead.

@dmbaturin dmbaturin closed this Aug 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

5 participants