Zhe Weng
cb958e5d69
net/nat: Clear entries when NAT will be disabled
...
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2022-12-24 12:05:20 +08:00
Zhe Weng
902a6dcad2
net/nat: Support isolation between multiple WAN devices by saving external ip
...
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2022-12-24 12:05:20 +08:00
Zhe Weng
7bd2195fde
net/nat: Fix misused d_draddr in select_port
...
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2022-12-23 19:40:19 +08:00
Zhe Weng
a9da1fff28
net/nat: Add auto reclaim logic for NAT entries.
...
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2022-12-22 20:20:12 +08:00
Zhe Weng
879c337e30
net/nat: Use hashtable to optimize performance
...
Performance tested on simulator:
Before optimization: -25% bandwidth @2k entries, -64% @10k entries
hashtable size= 2(1bit): -24% bandwidth @2k entries, -65% @10k entries
hashtable size= 4(2bits):-15% bandwidth @2k entries, -51% @10k entries
hashtable size= 32(5bits): -3% bandwidth @2k entries, -14% @10k entries
hashtable size=256(8bits): -1% bandwidth @2k entries, -3% @10k entries
Note: Tested on worst performance, the earliest entry will be the worst.
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2022-12-22 20:20:12 +08:00
Zhe Weng
9aefd6717c
net/nat: Add support for ICMP Error Message
...
Support DEST_UNREACHABLE, TIME_EXCEEDED and PARAMETER_PROBLEM ICMP types in NAT.
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2022-12-01 22:45:22 +08:00
Zhe Weng
a3a669a5f6
net/nat: Add UDP support
...
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2022-11-11 14:36:55 +08:00
Zhe Weng
8d401db5b9
net/nat: Add ICMP ECHO (REQUEST & REPLY) support
...
Support ICMP ECHO REQUEST & REPLY. Id of ICMP is processed like port of TCP in NAT. However, our ICMP stack doesn't have a method to manage id allocation like tcp_selectport(), the id is set by apps (like icmp_ping.c) without conflict avoidance, so not adding such conflict avoidance logic to ICMP stack when implementing NAT.
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2022-11-11 14:36:55 +08:00
Zhe Weng
f498102512
net: select NAT external port by tcp_selectport for TCP
...
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2022-11-11 14:36:55 +08:00
Zhe Weng
8239ddeef4
net/nat: Add TCP entry expiration logic
...
Add TCP entry expiration logic for NAT, with entries changed from sq to dq for fast removal.
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2022-11-11 14:36:55 +08:00
Zhe Weng
0a4e01d712
net: verify NAT port usage in tcp_selectport
...
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2022-11-11 14:36:55 +08:00
Zhe Weng
b595430578
net: add basic NAT workflow
...
Add basic functions for NAT (NAPT), remaining some logic unimplemented (UDP, ICMP, port assignment, etc). NAT for TCP can work now (unless port conflicts).
Outbound: LAN -> Forward -> NAT(only if targeting at WAN) -> WAN
Inbound: WAN -> NAT(only from WAN, change dest) -> Forward -> LAN
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2022-11-11 14:36:55 +08:00