ref: 6e4a1fda8c6105bc18aa7c26ff1fd28e18fec986
parent: d2a7d886624c56673a6d7ba7d6a7958d2be5b867
author: cinap_lenrek <[email protected]>
date: Sun Mar 13 13:16:54 EDT 2022
devip: allow setting the "trans" flag on a logical interface This makes the interface route have the "t"-flag, which causes packets routed to the interface to get source translated.
--- a/sys/src/9/ip/ipifc.c
+++ b/sys/src/9/ip/ipifc.c
@@ -465,8 +465,10 @@
memset(rem, 0, IPaddrlen);
switch(argc){
case 6:
- if(strcmp(argv[5], "proxy") == 0)
+ if(strstr(argv[5], "proxy") != 0)
type |= Rproxy;
+ if(strstr(argv[5], "trans") != 0)
+ type |= Rtrans;
/* fall through */
case 5:
mtu = strtoul(argv[4], 0, 0);
@@ -523,7 +525,7 @@
if(!lifc->onlink && lifcp->onlink){
lifc->onlink = 1;
addroute(f, lifc->remote, lifc->mask, ip, IPallbits,
- lifc->remote, lifc->type, ifc, tifc);
+ lifc->remote, lifc->type&~Rtrans, ifc, tifc);
if(v6addrtype(ip) != linklocalv6)
addroute(f, lifc->remote, lifc->mask, ip, IPnoaddr,
lifc->remote, lifc->type, ifc, tifc);
@@ -569,7 +571,7 @@
/* add route for this logical interface */
if(lifc->onlink){
- addroute(f, rem, mask, ip, IPallbits, rem, type, ifc, tifc);
+ addroute(f, rem, mask, ip, IPallbits, rem, type&~Rtrans, ifc, tifc);
if(v6addrtype(ip) != linklocalv6)
addroute(f, rem, mask, ip, IPnoaddr, rem, type, ifc, tifc);
}
@@ -664,7 +666,7 @@
if(lifc->onlink){
remroute(f, lifc->remote, lifc->mask,
lifc->local, IPallbits,
- lifc->remote, lifc->type, ifc, tifc);
+ lifc->remote, lifc->type&~Rtrans, ifc, tifc);
if(v6addrtype(lifc->local) != linklocalv6)
remroute(f, lifc->remote, lifc->mask,
lifc->local, IPnoaddr,
@@ -907,6 +909,8 @@
int h;
type |= (lifc->type & Rv4);
+ type &= ~Rtrans;
+
qlock(f->self);
if(waserror()){
qunlock(f->self);