Help me to add vpn as veth interface

hello i would like to add my vpn tun0 as interface in cake

it works for upload with cake but for download i have max speed i put you an example of configuration that i would like thank you

uci -q get dhcp.odhcpd.loglevel | grep "3" > /dev/null 2>&1 || {
uci set dhcp.odhcpd.loglevel="3"
uci commit && reload_config
}

## Add veth devices
ip link show veth0 > /dev/null 2>&1 || {
ip link add type veth
ip link add type vpn
sleep 10
}
ip link set veth0 up
ip link set veth1 up
ip link set veth1 promisc on
ip link set veth1 master br-lan
ip link set tun0 up
ip link set tun1 up
ip link set tun1 promisc on
ip link set tun1 master tun0
ip rule del priority 100 > /dev/null 2>&1
ip route del table 100 > /dev/null 2>&1
ip route add default dev veth0 table 100
ip rule add iif $WAN priority 100 table 100
ip -6 rule del priority 100 > /dev/null 2>&1
ip -6 route del table 100 > /dev/null 2>&1
ip -6 route add default dev veth0 table 100
ip -6 rule add iif $WAN priority 100 table 100

RTNETLINK answers: Not supported
RTNETLINK answers: File exists
RTNETLINK answers: File exists

by original script

What does it mean in your case?

The script launches the CAKE qdisc (like SQM would do), and you do not need SQM at all.

My question is why not use SQM instead? In SQM you can attach cake to the tun0 interface.

wan is my wan this is my outpout qdisc @moeller0

root@OpenWrt:~# tc -s qdisc
qdisc noqueue 0: dev lo root refcnt 2
 Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
 backlog 0b 0p requeues 0
qdisc fq_codel 0: dev eth0 root refcnt 2 limit 10240p flows 1024 quantum 1518 ta                                                                                                          rget 5ms interval 100ms memory_limit 4Mb ecn drop_batch 64
 Sent 903964393 bytes 1002912 pkt (dropped 0, overlimits 0 requeues 2)
 backlog 0b 0p requeues 2
  maxpacket 1442 drop_overlimit 0 new_flow_count 152 ecn_mark 0
  new_flows_len 0 old_flows_len 0
qdisc noqueue 0: dev lan1 root refcnt 2
 Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
 backlog 0b 0p requeues 0
qdisc noqueue 0: dev lan2 root refcnt 2
 Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
 backlog 0b 0p requeues 0
qdisc noqueue 0: dev lan3 root refcnt 2
 Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
 backlog 0b 0p requeues 0
qdisc noqueue 0: dev lan4 root refcnt 2
 Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
 backlog 0b 0p requeues 0
qdisc cake 800e: dev wan root refcnt 2 bandwidth 16Mbit diffserv4 dual-srchost n                                                                                                          at wash no-ack-filter split-gso rtt 100ms noatm overhead 38 mpu 84
 Sent 483758833 bytes 588753 pkt (dropped 269, overlimits 818337 requeues 0)
 backlog 0b 0p requeues 0
 memory used: 108032b of 4Mb
 capacity estimate: 16Mbit
 min/max network layer size:           28 /    1424
 min/max overhead-adjusted size:       84 /    1462
 average network hdr offset:           14

                   Bulk  Best Effort        Video        Voice
  thresh          1Mbit       16Mbit        8Mbit        4Mbit
  target         18.2ms          5ms          5ms          5ms
  interval        113ms        100ms        100ms        100ms
  pk_delay          0us       1.11ms          0us        137us
  av_delay          0us        115us          0us         10us
  sp_delay          0us          4us          0us          3us
  backlog            0b           0b           0b           0b
  pkts                0       588706            0          316
  bytes               0    484111376            0        14551
  way_inds            0            1            0            0
  way_miss            0         2228            0            3
  way_cols            0            0            0            0
  drops               0          269            0            0
  marks               0            0            0            0
  ack_drop            0            0            0            0
  sp_flows            0            0            0            0
  bk_flows            0            1            0            0
  un_flows            0            0            0            0
  max_len             0         1438            0          269
  quantum           300          488          300          300

qdisc noqueue 0: dev br-lan root refcnt 2
 Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
 backlog 0b 0p requeues 0
qdisc noqueue 0: dev wlan0 root refcnt 2
 Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
 backlog 0b 0p requeues 0
qdisc noqueue 0: dev wlan1 root refcnt 2
 Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
 backlog 0b 0p requeues 0
qdisc cake 800f: dev tun0 root refcnt 2 bandwidth 16Mbit diffserv4 dual-srchost                                                                                                           nat wash no-ack-filter split-gso rtt 100ms noatm overhead 38 mpu 84
 Sent 419755644 bytes 590830 pkt (dropped 5, overlimits 627949 requeues 0)
 backlog 0b 0p requeues 0
 memory used: 499968b of 4Mb
 capacity estimate: 16Mbit
 min/max network layer size:           31 /    1326
 min/max overhead-adjusted size:       84 /    1364
 average network hdr offset:            0

                   Bulk  Best Effort        Video        Voice
  thresh          1Mbit       16Mbit        8Mbit        4Mbit
  target           18ms          5ms          5ms          5ms
  interval        113ms        100ms        100ms        100ms
  pk_delay       9.67ms        131us        541us        888us
  av_delay       1.44ms         10us        124us         46us
  sp_delay         14us          3us          7us         29us
  backlog            0b           0b           0b           0b
  pkts           310173       217556        20075        43031
  bytes       394980720     13810027      3092167      7879296
  way_inds          212          417          937          280
  way_miss          878         2351         3430         2117
  way_cols            0            0            0            0
  drops               5            0            0            0
  marks               0            0            0            0
  ack_drop            0            0            0            0
  sp_flows            1            1            0            6
  bk_flows            0            0            0            0
  un_flows            0            0            0            0
  max_len         18224          569         1076         1144
  quantum           300          488          300          300

qdisc cake 800d: dev veth0 root refcnt 2 bandwidth 42Mbit diffserv4 dual-dsthost                                                                                                           nonat nowash ingress no-ack-filter split-gso rtt 100ms noatm overhead 38 mpu 84                                                                                                          
 Sent 417121004 bytes 408886 pkt (dropped 3400, overlimits 564342 requeues 0)
 backlog 0b 0p requeues 0
 memory used: 2992Kb of 4Mb
 capacity estimate: 42Mbit
 min/max network layer size:           28 /    1468
 min/max overhead-adjusted size:       84 /    1506
 average network hdr offset:           14

                   Bulk  Best Effort        Video        Voice
  thresh       2625Kbit       42Mbit       21Mbit    10500Kbit
  target         6.92ms          5ms          5ms          5ms
  interval        102ms        100ms        100ms        100ms
  pk_delay       1.83ms        539us        528us         71us
  av_delay        372us        239us         91us          9us
  sp_delay         10us          5us          5us          5us
  backlog            0b           0b           0b           0b
  pkts            52493       217191       126800        15802
  bytes        70154274    285809500     58033133      7667849
  way_inds            0            0         1530           16
  way_miss           27          148         2405          147
  way_cols            0            0            0            0
  drops             965         2413           22            0
  marks               0            0            0            0
  ack_drop            0            0            0            0
  sp_flows            0            0            1            0
  bk_flows            0            0            1            0
  un_flows            0            0            0            0
  max_len          1340         1454         1482         1269
  quantum           300         1281          640          320

qdisc noqueue 0: dev veth1 root refcnt 2
 Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
 backlog 0b 0p requeues 0
root@OpenWrt:~#

@mk24 yes i can but i prefee automaticly use sqm in script

i has modified like this @elan

## Go to "Network -> Interfaces" and write the name of your "WAN" interface.
WAN="wan"
VPN="tun0"
ip link set veth0 up
ip link set veth1 up
ip link set veth1 promisc on
ip link set veth1 master br-lan
ip rule del priority 100 > /dev/null 2>&1
ip route del table 100 > /dev/null 2>&1
ip route add default dev veth0 table 100
ip rule add iif $WAN priority 100 table 100
ip -6 rule del priority 100 > /dev/null 2>&1
ip -6 route del table 100 > /dev/null 2>&1
ip -6 route add default dev veth0 table 100
ip -6 rule add iif $WAN priority 100 table 100
ip rule add iif $VPN priority 100 table 100
ip -6 rule del priority 100 > /dev/null 2>&1
ip -6 route del table 100 > /dev/null 2>&1
ip -6 route add default dev veth0 table 100
ip -6 rule add iif $VPN priority 100 table 100
## Delete the old qdiscs created by the script
tc qdisc del dev veth0 root > /dev/null 2>&1
tc qdisc del dev $WAN root > /dev/null 2>&1
tc qdisc del dev $VPN root > /dev/null 2>&1

############################################################

### CAKE qdiscs ###

## Inbound / Ingress
if [ "$BANDWIDTH_DOWN" != "" ]; then
    tc qdisc add dev veth0 root cake $BANDWIDTH_DOWN_CAKE $AUTORATE_INGRESS_CAKE $PRIORITY_QUEUE_INGRESS $HOST_ISOLATION_INGRESS $NAT_INGRESS $WASH_INGRESS $INGRESS_MODE $RTT $COMMON_LINK_PRESETS $ETHER_VLAN_KEYWORD $LINK_COMPENSATION $OVERHEAD $MPU $EXTRA_PARAMETERS_INGRESS
fi

## Outbound / Egress
if [ "$BANDWIDTH_UP" != "" ]; then
    tc qdisc add dev $WAN root cake $BANDWIDTH_UP_CAKE $PRIORITY_QUEUE_EGRESS $HOST_ISOLATION_EGRESS $NAT_EGRESS $WASH_EGRESS $ACK_FILTER_EGRESS $RTT $COMMON_LINK_PRESETS $ETHER_VLAN_KEYWORD $LINK_COMPENSATION $OVERHEAD $MPU $EXTRA_PARAMETERS_EGRESS
fi

# Outbound / Egress
if [ "$BANDWIDTH_UP" != "" ]; then
    tc qdisc add dev $VPN root cake $BANDWIDTH_UP_CAKE $PRIORITY_QUEUE_EGRESS $HOST_ISOLATION_EGRESS $NAT_EGRESS $WASH_EGRESS $ACK_FILTER_EGRESS $RTT $COMMON_LINK_PRESETS $ETHER_VLAN_KEYWORD $LINK_COMPENSATION $OVERHEAD $MPU $EXTRA_PARAMETERS_EGRESS
fi

bufferbloat with vpn my download is bad but my upload si good

in the past in the script of @dlakelan
he has created a script for vpn with nftables

example

define wan = vpn tun0


in openwrtnftables

but his a little different for this script

i see the interface vpn tun0 in firewall

86.2 MBTraffic matched by rule: 1.1 MPackets, 886.2 MBytesAddress family is IPv4	Set header field ip.dscp to cs1
#Rule comment: Wash all ISP DSCP marks to CS1 (IPv6)381.7 KBTraffic matched by rule: 1.3 KPackets, 381.7 KBytesAddress family is IPv6	Set header field ip6.dscp to cs1
#Rule comment: DSCP marking rules for ports (IPv4)Address family is IPv4	Continue in dscp_marking_ports_ipv4
#Rule comment: DSCP marking rules for ports (IPv6)Address family is IPv6	Continue in dscp_marking_ports_ipv6
#Rule comment: DSCP marking rules for IP addresses (IPv4)Address family is IPv4	Continue in dscp_marking_ip_addresses_ipv4
#Rule comment: DSCP marking rules for IP addresses (IPv6)Address family is IPv6	Continue in dscp_marking_ip_addresses_ipv6
#Rule comment: Zone wan IPv4/IPv6 ingress MTU fixingIngress device name is wanTCP flags is syn	Set header field TCP MSS to Effective route MTU
#Rule comment: Zone wan IPv4/IPv6 egress MTU fixingEgress device name is wanTCP flags is syn	Set header field TCP MSS to Effective route MTU
#Rule comment: Zone vpn IPv4/IPv6 ingress MTU fixingIngress device name is tun0TCP flags is syn	Set header field TCP MSS to Effective route MTU
#Rule comment: Zone vpn IPv4/IPv6 egress MTU fixingEgress device name is tun0TCP flags is syn	Set header field TCP MSS to Effective route MTU

ok i will try