diff --git a/data/templates/firewall/nftables.j2 b/data/templates/firewall/nftables.j2
index 3f7906628..4851e3a05 100644
--- a/data/templates/firewall/nftables.j2
+++ b/data/templates/firewall/nftables.j2
@@ -1,333 +1,340 @@
 #!/usr/sbin/nft -f
 
 {% import 'firewall/nftables-defines.j2' as group_tmpl %}
 {% import 'firewall/nftables-bridge.j2' as bridge_tmpl %}
 {% import 'firewall/nftables-offload.j2' as offload_tmpl %}
 {% import 'firewall/nftables-zone.j2' as zone_tmpl %}
 
 flush chain raw FW_CONNTRACK
 flush chain ip6 raw FW_CONNTRACK
 
+flush chain raw vyos_global_rpfilter
+flush chain ip6 raw vyos_global_rpfilter
+
 table raw {
     chain FW_CONNTRACK {
         {{ ipv4_conntrack_action }}
     }
+
+    chain vyos_global_rpfilter {
+{% if global_options.source_validation is vyos_defined('loose') %}
+        fib saddr oif 0 counter drop
+{% elif global_options.source_validation is vyos_defined('strict') %}
+        fib saddr . iif oif 0 counter drop
+{% endif %}
+        return
+    }
 }
 
 table ip6 raw {
     chain FW_CONNTRACK {
         {{ ipv6_conntrack_action }}
     }
-}
 
-{% if first_install is not vyos_defined %}
-delete table inet vyos_global_rpfilter
-{% endif %}
-table inet vyos_global_rpfilter {
-    chain PREROUTING {
-        type filter hook prerouting priority -300; policy accept;
-{% if global_options.source_validation is vyos_defined('loose') %}
+    chain vyos_global_rpfilter {
+{% if global_options.ipv6_source_validation is vyos_defined('loose') %}
         fib saddr oif 0 counter drop
-{% elif global_options.source_validation is vyos_defined('strict') %}
+{% elif global_options.ipv6_source_validation is vyos_defined('strict') %}
         fib saddr . iif oif 0 counter drop
 {% endif %}
+        return
     }
 }
 
 {% if first_install is not vyos_defined %}
 delete table ip vyos_filter
 {% endif %}
 table ip vyos_filter {
 {% if ipv4 is vyos_defined %}
 {%     if flowtable is vyos_defined %}
 {%         for name, flowtable_conf in flowtable.items() %}
 {{ offload_tmpl.flowtable(name, flowtable_conf) }}
 {%         endfor %}
 {%     endif %}
 
 {%     set ns = namespace(sets=[]) %}
 {%     if ipv4.forward is vyos_defined %}
 {%         for prior, conf in ipv4.forward.items() %}
     chain VYOS_FORWARD_{{ prior }} {
         type filter hook forward priority {{ prior }}; policy accept;
 {%             if global_options.state_policy is vyos_defined %}
         jump VYOS_STATE_POLICY
 {%             endif %}
 {%             if conf.rule is vyos_defined %}
 {%                 for rule_id, rule_conf in conf.rule.items() if rule_conf.disable is not vyos_defined %}
         {{ rule_conf | nft_rule('FWD', prior, rule_id) }}
 {%                     if rule_conf.recent is vyos_defined %}
 {%                         set ns.sets = ns.sets + ['FWD_' + prior + '_' + rule_id] %}
 {%                     endif %}
 {%                 endfor %}
 {%             endif %}
         {{ conf | nft_default_rule('FWD-filter') }}
     }
 {%         endfor %}
 {%     endif %}
 
 {%     if ipv4.input is vyos_defined %}
 {%         for prior, conf in ipv4.input.items() %}
     chain VYOS_INPUT_{{ prior }} {
         type filter hook input priority {{ prior }}; policy accept;
 {%             if global_options.state_policy is vyos_defined %}
         jump VYOS_STATE_POLICY
 {%             endif %}
 {%             if conf.rule is vyos_defined %}
 {%                 for rule_id, rule_conf in conf.rule.items() if rule_conf.disable is not vyos_defined %}
         {{ rule_conf | nft_rule('INP',prior, rule_id) }}
 {%                     if rule_conf.recent is vyos_defined %}
 {%                         set ns.sets = ns.sets + ['INP_' + prior + '_' + rule_id] %}
 {%                     endif %}
 {%                 endfor %}
 {%             endif %}
         {{ conf | nft_default_rule('INP-filter') }}
     }
 {%         endfor %}
 {%     endif %}
 
 {%     if ipv4.output is vyos_defined %}
 {%         for prior, conf in ipv4.output.items() %}
     chain VYOS_OUTPUT_{{ prior }} {
         type filter hook output priority {{ prior }}; policy accept;
 {%             if global_options.state_policy is vyos_defined %}
         jump VYOS_STATE_POLICY
 {%             endif %}
 {%             if conf.rule is vyos_defined %}
 {%                 for rule_id, rule_conf in conf.rule.items() if rule_conf.disable is not vyos_defined %}
         {{ rule_conf | nft_rule('OUT', prior, rule_id) }}
 {%                     if rule_conf.recent is vyos_defined %}
 {%                         set ns.sets = ns.sets + ['OUT_' + prior + '_' + rule_id] %}
 {%                     endif %}
 {%                 endfor %}
 {%             endif %}
         {{ conf | nft_default_rule('OUT-filter') }}
     }
 {%         endfor %}
 {%     endif %}
     chain VYOS_FRAG_MARK {
         type filter hook prerouting priority -450; policy accept;
         ip frag-off & 0x3fff != 0 meta mark set 0xffff1 return
     }
 {%     if ipv4.prerouting is vyos_defined %}
 {%         for prior, conf in ipv4.prerouting.items() %}
     chain VYOS_PREROUTING_{{ prior }} {
         type filter hook prerouting priority {{ prior }}; policy accept;
 {%             if conf.rule is vyos_defined %}
 {%                 for rule_id, rule_conf in conf.rule.items() if rule_conf.disable is not vyos_defined %}
         {{ rule_conf | nft_rule('PRE', prior, rule_id) }}
 {%                     if rule_conf.recent is vyos_defined %}
 {%                         set ns.sets = ns.sets + ['PRE_' + prior + '_' + rule_id] %}
 {%                     endif %}
 {%                 endfor %}
 {%             endif %}
         {{ conf | nft_default_rule('PRE-filter') }}
     }
 {%         endfor %}
 {%     endif %}
 
 {%     if ipv4.name is vyos_defined %}
 {%         for name_text, conf in ipv4.name.items() %}
     chain NAME_{{ name_text }} {
 {%             if conf.rule is vyos_defined %}
 {%                 for rule_id, rule_conf in conf.rule.items() if rule_conf.disable is not vyos_defined %}
         {{ rule_conf | nft_rule('NAM', name_text, rule_id) }}
 {%                     if rule_conf.recent is vyos_defined %}
 {%                         set ns.sets = ns.sets + ['NAM_' + name_text + '_' + rule_id] %}
 {%                     endif %}
 {%                 endfor %}
 {%             endif %}
         {{ conf | nft_default_rule(name_text) }}
     }
 {%         endfor %}
 {%     endif %}
 
 {%     for set_name in ns.sets %}
     set RECENT_{{ set_name }} {
         type ipv4_addr
         size 65535
         flags dynamic
     }
 {%     endfor %}
 {%     for set_name in ip_fqdn %}
     set FQDN_{{ set_name }} {
         type ipv4_addr
         flags interval
     }
 {%     endfor %}
 {%     if geoip_updated.name is vyos_defined %}
 {%         for setname in geoip_updated.name %}
     set {{ setname }} {
         type ipv4_addr
         flags interval
     }
 {%         endfor %}
 {%     endif %}
 {% endif %}
 {{ group_tmpl.groups(group, False, True) }}
 
 {% if zone is vyos_defined %}
 {{ zone_tmpl.zone_chains(zone, False, global_options.state_policy is vyos_defined) }}
 {% endif %}
 {% if global_options.state_policy is vyos_defined %}
     chain VYOS_STATE_POLICY {
 {%     if global_options.state_policy.established is vyos_defined %}
         {{ global_options.state_policy.established | nft_state_policy('established') }}
 {%     endif %}
 {%     if global_options.state_policy.invalid is vyos_defined %}
         {{ global_options.state_policy.invalid | nft_state_policy('invalid') }}
 {%     endif %}
 {%     if global_options.state_policy.related is vyos_defined %}
         {{ global_options.state_policy.related | nft_state_policy('related') }}
 {%     endif %}
         return
     }
 {% endif %}
 }
 
 {% if first_install is not vyos_defined %}
 delete table ip6 vyos_filter
 {% endif %}
 table ip6 vyos_filter {
 {% if ipv6 is vyos_defined %}
 {%     if flowtable is vyos_defined %}
 {%         for name, flowtable_conf in flowtable.items() %}
 {{ offload_tmpl.flowtable(name, flowtable_conf) }}
 {%         endfor %}
 {%     endif %}
 
 {%     set ns = namespace(sets=[]) %}
 {%     if ipv6.forward is vyos_defined %}
 {%         for prior, conf in ipv6.forward.items() %}
     chain VYOS_IPV6_FORWARD_{{ prior }} {
         type filter hook forward priority {{ prior }}; policy accept;
 {%             if global_options.state_policy is vyos_defined %}
         jump VYOS_STATE_POLICY6
 {%             endif %}
 {%             if conf.rule is vyos_defined %}
 {%                 for rule_id, rule_conf in conf.rule.items() if rule_conf.disable is not vyos_defined %}
         {{ rule_conf | nft_rule('FWD', prior, rule_id ,'ip6') }}
 {%                     if rule_conf.recent is vyos_defined %}
 {%                         set ns.sets = ns.sets + ['FWD_' + prior + '_' + rule_id] %}
 {%                     endif %}
 {%                 endfor %}
 {%             endif %}
         {{ conf | nft_default_rule('FWD-filter', ipv6=True) }}
     }
 {%         endfor %}
 {%     endif %}
 
 {%     if ipv6.input is vyos_defined %}
 {%         for prior, conf in ipv6.input.items() %}
     chain VYOS_IPV6_INPUT_{{ prior }} {
         type filter hook input priority {{ prior }}; policy accept;
 {%             if global_options.state_policy is vyos_defined %}
         jump VYOS_STATE_POLICY6
 {%             endif %}
 {%             if conf.rule is vyos_defined %}
 {%                 for rule_id, rule_conf in conf.rule.items() if rule_conf.disable is not vyos_defined %}
         {{ rule_conf | nft_rule('INP', prior, rule_id ,'ip6') }}
 {%                     if rule_conf.recent is vyos_defined %}
 {%                         set ns.sets = ns.sets + ['INP_' + prior + '_' + rule_id] %}
 {%                     endif %}
 {%                 endfor %}
 {%             endif %}
         {{ conf | nft_default_rule('INP-filter', ipv6=True) }}
     }
 {%         endfor %}
 {%     endif %}
 
 {%     if ipv6.output is vyos_defined %}
 {%         for prior, conf in ipv6.output.items() %}
     chain VYOS_IPV6_OUTPUT_{{ prior }} {
         type filter hook output priority {{ prior }}; policy accept;
 {%             if global_options.state_policy is vyos_defined %}
         jump VYOS_STATE_POLICY6
 {%             endif %}
 {%             if conf.rule is vyos_defined %}
 {%                 for rule_id, rule_conf in conf.rule.items() if rule_conf.disable is not vyos_defined %}
         {{ rule_conf | nft_rule('OUT', prior, rule_id ,'ip6') }}
 {%                     if rule_conf.recent is vyos_defined %}
 {%                         set ns.sets = ns.sets + ['OUT_ ' + prior + '_' + rule_id] %}
 {%                     endif %}
 {%                 endfor %}
 {%             endif %}
         {{ conf | nft_default_rule('OUT-filter', ipv6=True) }}
     }
 {%         endfor %}
 {%     endif %}
 
     chain VYOS_FRAG6_MARK {
         type filter hook prerouting priority -450; policy accept;
         exthdr frag exists meta mark set 0xffff1 return
     }
 
 {%     if ipv6.name is vyos_defined %}
 {%         for name_text, conf in ipv6.name.items() %}
     chain NAME6_{{ name_text }} {
 {%             if conf.rule is vyos_defined %}
 {%                 for rule_id, rule_conf in conf.rule.items() if rule_conf.disable is not vyos_defined %}
         {{ rule_conf | nft_rule('NAM', name_text, rule_id, 'ip6') }}
 {%                     if rule_conf.recent is vyos_defined %}
 {%                         set ns.sets = ns.sets + ['NAM_' + name_text + '_' + rule_id] %}
 {%                     endif %}
 {%                 endfor %}
 {%             endif %}
         {{ conf | nft_default_rule(name_text, ipv6=True) }}
     }
 {%         endfor %}
 {%     endif %}
 
 {%     for set_name in ns.sets %}
     set RECENT6_{{ set_name }} {
         type ipv6_addr
         size 65535
         flags dynamic
     }
 {%     endfor %}
 {%     for set_name in ip6_fqdn %}
     set FQDN_{{ set_name }} {
         type ipv6_addr
         flags interval
     }
 {%     endfor %}
 {%     if geoip_updated.ipv6_name is vyos_defined %}
 {%         for setname in geoip_updated.ipv6_name %}
     set {{ setname }} {
         type ipv6_addr
         flags interval
     }
 {%         endfor %}
 {%     endif %}
 {% endif %}
 {{ group_tmpl.groups(group, True, True) }}
 
 {% if zone is vyos_defined %}
 {{ zone_tmpl.zone_chains(zone, True, global_options.state_policy is vyos_defined) }}
 {% endif %}
 {% if global_options.state_policy is vyos_defined %}
     chain VYOS_STATE_POLICY6 {
 {%     if global_options.state_policy.established is vyos_defined %}
         {{ global_options.state_policy.established | nft_state_policy('established') }}
 {%     endif %}
 {%     if global_options.state_policy.invalid is vyos_defined %}
         {{ global_options.state_policy.invalid | nft_state_policy('invalid') }}
 {%     endif %}
 {%     if global_options.state_policy.related is vyos_defined %}
         {{ global_options.state_policy.related | nft_state_policy('related') }}
 {%     endif %}
         return
     }
 {% endif %}
 
 }
 
 ## Bridge Firewall
 {% if first_install is not vyos_defined %}
 delete table bridge vyos_filter
 {% endif %}
 table bridge vyos_filter {
 {{ bridge_tmpl.bridge(bridge) }}
 {{ group_tmpl.groups(group, False, False) }}
 
 }
\ No newline at end of file
diff --git a/data/vyos-firewall-init.conf b/data/vyos-firewall-init.conf
index 41e7627f5..b0026fdf3 100644
--- a/data/vyos-firewall-init.conf
+++ b/data/vyos-firewall-init.conf
@@ -1,114 +1,128 @@
 #!/usr/sbin/nft -f
 
 # Required by wanloadbalance
 table ip nat {
     chain VYOS_PRE_SNAT_HOOK {
         type nat hook postrouting priority 99; policy accept;
         return
     }
 }
 
 table inet mangle {
     chain FORWARD {
         type filter hook forward priority -150; policy accept;
     }
 }
 
 table raw {
     chain VYOS_TCP_MSS {
         type filter hook forward priority -300; policy accept;
     }
 
+    chain vyos_global_rpfilter {
+        return
+    }
+
+    chain vyos_rpfilter {
+        type filter hook prerouting priority -300; policy accept;
+        counter jump vyos_global_rpfilter
+    }
+
     chain PREROUTING {
         type filter hook prerouting priority -300; policy accept;
         counter jump VYOS_CT_IGNORE
         counter jump VYOS_CT_TIMEOUT
         counter jump VYOS_CT_PREROUTING_HOOK
         counter jump FW_CONNTRACK
         notrack
     }
 
     chain OUTPUT {
         type filter hook output priority -300; policy accept;
         counter jump VYOS_CT_IGNORE
         counter jump VYOS_CT_TIMEOUT
         counter jump VYOS_CT_OUTPUT_HOOK
         counter jump FW_CONNTRACK
         notrack
     }
 
     ct helper rpc_tcp {
         type "rpc" protocol tcp;
     }
 
     ct helper rpc_udp {
         type "rpc" protocol udp;
     }
 
     ct helper tns_tcp {
         type "tns" protocol tcp;
     }
 
     chain VYOS_CT_HELPER {
         ct helper set "rpc_tcp" tcp dport {111} return
         ct helper set "rpc_udp" udp dport {111} return
         ct helper set "tns_tcp" tcp dport {1521,1525,1536} return
         return
     }
 
     chain VYOS_CT_IGNORE {
         return
     }
 
     chain VYOS_CT_TIMEOUT {
         return
     }
 
     chain VYOS_CT_PREROUTING_HOOK {
         return
     }
 
     chain VYOS_CT_OUTPUT_HOOK {
         return
     }
 
     chain FW_CONNTRACK {
         return
     }
 }
 
 table ip6 raw {
     chain VYOS_TCP_MSS {
         type filter hook forward priority -300; policy accept;
     }
 
+    chain vyos_global_rpfilter {
+        return
+    }
+
     chain vyos_rpfilter {
         type filter hook prerouting priority -300; policy accept;
+        counter jump vyos_global_rpfilter
     }
 
     chain PREROUTING {
         type filter hook prerouting priority -300; policy accept;
         counter jump VYOS_CT_PREROUTING_HOOK
         counter jump FW_CONNTRACK
         notrack
     }
 
     chain OUTPUT {
         type filter hook output priority -300; policy accept;
         counter jump VYOS_CT_OUTPUT_HOOK
         counter jump FW_CONNTRACK
         notrack
     }
 
     chain VYOS_CT_PREROUTING_HOOK {
         return
     }
 
     chain VYOS_CT_OUTPUT_HOOK {
         return
     }
 
     chain FW_CONNTRACK {
         return
     }
 }
diff --git a/interface-definitions/include/firewall/global-options.xml.i b/interface-definitions/include/firewall/global-options.xml.i
index 3026b54ab..415d85f05 100644
--- a/interface-definitions/include/firewall/global-options.xml.i
+++ b/interface-definitions/include/firewall/global-options.xml.i
@@ -1,289 +1,313 @@
 <!-- include start from firewall/global-options.xml.i -->
 <node name="global-options">
   <properties>
     <help>Global Options</help>
   </properties>
   <children>
     <leafNode name="all-ping">
       <properties>
         <help>Policy for handling of all IPv4 ICMP echo requests</help>
         <completionHelp>
           <list>enable disable</list>
         </completionHelp>
         <valueHelp>
           <format>enable</format>
           <description>Enable processing of all IPv4 ICMP echo requests</description>
         </valueHelp>
         <valueHelp>
           <format>disable</format>
           <description>Disable processing of all IPv4 ICMP echo requests</description>
         </valueHelp>
         <constraint>
           <regex>(enable|disable)</regex>
         </constraint>
       </properties>
       <defaultValue>enable</defaultValue>
     </leafNode>
     <leafNode name="broadcast-ping">
       <properties>
         <help>Policy for handling broadcast IPv4 ICMP echo and timestamp requests</help>
         <completionHelp>
           <list>enable disable</list>
         </completionHelp>
         <valueHelp>
           <format>enable</format>
           <description>Enable processing of broadcast IPv4 ICMP echo/timestamp requests</description>
         </valueHelp>
         <valueHelp>
           <format>disable</format>
           <description>Disable processing of broadcast IPv4 ICMP echo/timestamp requests</description>
         </valueHelp>
         <constraint>
           <regex>(enable|disable)</regex>
         </constraint>
       </properties>
       <defaultValue>disable</defaultValue>
     </leafNode>
     <leafNode name="ip-src-route">
       <properties>
         <help>Policy for handling IPv4 packets with source route option</help>
         <completionHelp>
           <list>enable disable</list>
         </completionHelp>
         <valueHelp>
           <format>enable</format>
           <description>Enable processing of IPv4 packets with source route option</description>
         </valueHelp>
         <valueHelp>
           <format>disable</format>
           <description>Disable processing of IPv4 packets with source route option</description>
         </valueHelp>
         <constraint>
           <regex>(enable|disable)</regex>
         </constraint>
       </properties>
       <defaultValue>disable</defaultValue>
     </leafNode>
     <leafNode name="log-martians">
       <properties>
         <help>Policy for logging IPv4 packets with invalid addresses</help>
         <completionHelp>
           <list>enable disable</list>
         </completionHelp>
         <valueHelp>
           <format>enable</format>
           <description>Enable logging of IPv4 packets with invalid addresses</description>
         </valueHelp>
         <valueHelp>
           <format>disable</format>
           <description>Disable logging of Ipv4 packets with invalid addresses</description>
         </valueHelp>
         <constraint>
           <regex>(enable|disable)</regex>
         </constraint>
       </properties>
       <defaultValue>enable</defaultValue>
     </leafNode>
     <leafNode name="receive-redirects">
       <properties>
         <help>Policy for handling received IPv4 ICMP redirect messages</help>
         <completionHelp>
           <list>enable disable</list>
         </completionHelp>
         <valueHelp>
           <format>enable</format>
           <description>Enable processing of received IPv4 ICMP redirect messages</description>
         </valueHelp>
         <valueHelp>
           <format>disable</format>
           <description>Disable processing of received IPv4 ICMP redirect messages</description>
         </valueHelp>
         <constraint>
           <regex>(enable|disable)</regex>
         </constraint>
       </properties>
       <defaultValue>disable</defaultValue>
     </leafNode>
     <leafNode name="resolver-cache">
       <properties>
         <help>Retains last successful value if domain resolution fails</help>
         <valueless/>
       </properties>
     </leafNode>
     <leafNode name="resolver-interval">
       <properties>
         <help>Domain resolver update interval</help>
         <valueHelp>
           <format>u32:10-3600</format>
           <description>Interval (seconds)</description>
         </valueHelp>
         <constraint>
           <validator name="numeric" argument="--range 10-3600"/>
         </constraint>
       </properties>
       <defaultValue>300</defaultValue>
     </leafNode>
     <leafNode name="send-redirects">
       <properties>
         <help>Policy for sending IPv4 ICMP redirect messages</help>
         <completionHelp>
           <list>enable disable</list>
         </completionHelp>
         <valueHelp>
           <format>enable</format>
           <description>Enable sending IPv4 ICMP redirect messages</description>
         </valueHelp>
         <valueHelp>
           <format>disable</format>
           <description>Disable sending IPv4 ICMP redirect messages</description>
         </valueHelp>
         <constraint>
           <regex>(enable|disable)</regex>
         </constraint>
       </properties>
       <defaultValue>enable</defaultValue>
     </leafNode>
     <leafNode name="source-validation">
       <properties>
-        <help>Policy for source validation by reversed path, as specified in RFC3704</help>
+        <help>Policy for IPv4 source validation by reversed path, as specified in RFC3704</help>
         <completionHelp>
           <list>strict loose disable</list>
         </completionHelp>
         <valueHelp>
           <format>strict</format>
-          <description>Enable Strict Reverse Path Forwarding as defined in RFC3704</description>
+          <description>Enable IPv4 Strict Reverse Path Forwarding as defined in RFC3704</description>
         </valueHelp>
         <valueHelp>
           <format>loose</format>
-          <description>Enable Loose Reverse Path Forwarding as defined in RFC3704</description>
+          <description>Enable IPv4 Loose Reverse Path Forwarding as defined in RFC3704</description>
         </valueHelp>
         <valueHelp>
           <format>disable</format>
-          <description>No source validation</description>
+          <description>No IPv4 source validation</description>
         </valueHelp>
         <constraint>
           <regex>(strict|loose|disable)</regex>
         </constraint>
       </properties>
       <defaultValue>disable</defaultValue>
     </leafNode>
     <node name="state-policy">
       <properties>
         <help>Global firewall state-policy</help>
       </properties>
       <children>
         <node name="established">
           <properties>
             <help>Global firewall policy for packets part of an established connection</help>
           </properties>
           <children>
             #include <include/firewall/action-accept-drop-reject.xml.i>
             #include <include/firewall/log.xml.i>
             #include <include/firewall/rule-log-level.xml.i>
           </children>
         </node>
         <node name="invalid">
           <properties>
             <help>Global firewall policy for packets part of an invalid connection</help>
           </properties>
           <children>
             #include <include/firewall/action-accept-drop-reject.xml.i>
             #include <include/firewall/log.xml.i>
             #include <include/firewall/rule-log-level.xml.i>
           </children>
         </node>
         <node name="related">
           <properties>
             <help>Global firewall policy for packets part of a related connection</help>
           </properties>
           <children>
             #include <include/firewall/action-accept-drop-reject.xml.i>
             #include <include/firewall/log.xml.i>
             #include <include/firewall/rule-log-level.xml.i>
           </children>
         </node>
       </children>
     </node>
     <leafNode name="syn-cookies">
       <properties>
         <help>Policy for using TCP SYN cookies with IPv4</help>
         <completionHelp>
           <list>enable disable</list>
         </completionHelp>
         <valueHelp>
           <format>enable</format>
           <description>Enable use of TCP SYN cookies with IPv4</description>
         </valueHelp>
         <valueHelp>
           <format>disable</format>
           <description>Disable use of TCP SYN cookies with IPv4</description>
         </valueHelp>
         <constraint>
           <regex>(enable|disable)</regex>
         </constraint>
       </properties>
       <defaultValue>enable</defaultValue>
     </leafNode>
     <leafNode name="twa-hazards-protection">
       <properties>
         <help>RFC1337 TCP TIME-WAIT assasination hazards protection</help>
         <completionHelp>
           <list>enable disable</list>
         </completionHelp>
         <valueHelp>
           <format>enable</format>
           <description>Enable RFC1337 TIME-WAIT hazards protection</description>
         </valueHelp>
         <valueHelp>
           <format>disable</format>
           <description>Disable RFC1337 TIME-WAIT hazards protection</description>
         </valueHelp>
         <constraint>
           <regex>(enable|disable)</regex>
         </constraint>
       </properties>
       <defaultValue>disable</defaultValue>
     </leafNode>
     <leafNode name="ipv6-receive-redirects">
       <properties>
         <help>Policy for handling received ICMPv6 redirect messages</help>
         <completionHelp>
           <list>enable disable</list>
         </completionHelp>
         <valueHelp>
           <format>enable</format>
           <description>Enable processing of received ICMPv6 redirect messages</description>
         </valueHelp>
         <valueHelp>
           <format>disable</format>
           <description>Disable processing of received ICMPv6 redirect messages</description>
         </valueHelp>
         <constraint>
           <regex>(enable|disable)</regex>
         </constraint>
       </properties>
       <defaultValue>disable</defaultValue>
     </leafNode>
+    <leafNode name="ipv6-source-validation">
+      <properties>
+        <help>Policy for IPv6 source validation by reversed path, as specified in RFC3704</help>
+        <completionHelp>
+          <list>strict loose disable</list>
+        </completionHelp>
+        <valueHelp>
+          <format>strict</format>
+          <description>Enable IPv6 Strict Reverse Path Forwarding as defined in RFC3704</description>
+        </valueHelp>
+        <valueHelp>
+          <format>loose</format>
+          <description>Enable IPv6 Loose Reverse Path Forwarding as defined in RFC3704</description>
+        </valueHelp>
+        <valueHelp>
+          <format>disable</format>
+          <description>No IPv6 source validation</description>
+        </valueHelp>
+        <constraint>
+          <regex>(strict|loose|disable)</regex>
+        </constraint>
+      </properties>
+      <defaultValue>disable</defaultValue>
+    </leafNode>
     <leafNode name="ipv6-src-route">
       <properties>
         <help>Policy for handling IPv6 packets with routing extension header</help>
         <completionHelp>
           <list>enable disable</list>
         </completionHelp>
         <valueHelp>
           <format>enable</format>
           <description>Enable processing of IPv6 packets with routing header type 2</description>
         </valueHelp>
         <valueHelp>
           <format>disable</format>
           <description>Disable processing of IPv6 packets with routing header</description>
         </valueHelp>
         <constraint>
           <regex>(enable|disable)</regex>
         </constraint>
       </properties>
       <defaultValue>disable</defaultValue>
     </leafNode>
   </children>
 </node>
 <!-- include end -->
diff --git a/python/vyos/ifconfig/interface.py b/python/vyos/ifconfig/interface.py
index a038ef28d..c793f6199 100644
--- a/python/vyos/ifconfig/interface.py
+++ b/python/vyos/ifconfig/interface.py
@@ -1,1838 +1,1825 @@
 # Copyright 2019-2023 VyOS maintainers and contributors <maintainers@vyos.io>
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
 # License as published by the Free Software Foundation; either
 # version 2.1 of the License, or (at your option) any later version.
 #
 # This library is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 # Lesser General Public License for more details.
 #
 # You should have received a copy of the GNU Lesser General Public
 # License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 
 import os
 import re
 import json
 import jmespath
 
 from copy import deepcopy
 from glob import glob
 
 from ipaddress import IPv4Network
 from netifaces import ifaddresses
 # this is not the same as socket.AF_INET/INET6
 from netifaces import AF_INET
 from netifaces import AF_INET6
 
 from vyos import ConfigError
 from vyos.configdict import list_diff
 from vyos.configdict import dict_merge
 from vyos.configdict import get_vlan_ids
 from vyos.defaults import directories
 from vyos.template import render
 from vyos.utils.network import mac2eui64
 from vyos.utils.dict import dict_search
 from vyos.utils.file import read_file
 from vyos.utils.network import get_interface_config
 from vyos.utils.network import get_interface_namespace
 from vyos.utils.process import is_systemd_service_active
 from vyos.template import is_ipv4
 from vyos.template import is_ipv6
 from vyos.utils.network import is_intf_addr_assigned
 from vyos.utils.network import is_ipv6_link_local
 from vyos.utils.assertion import assert_boolean
 from vyos.utils.assertion import assert_list
 from vyos.utils.assertion import assert_mac
 from vyos.utils.assertion import assert_mtu
 from vyos.utils.assertion import assert_positive
 from vyos.utils.assertion import assert_range
 
 from vyos.ifconfig.control import Control
 from vyos.ifconfig.vrrp import VRRP
 from vyos.ifconfig.operational import Operational
 from vyos.ifconfig import Section
 
 from netaddr import EUI
 from netaddr import mac_unix_expanded
 
 link_local_prefix = 'fe80::/64'
 
 class Interface(Control):
     # This is the class which will be used to create
     # self.operational, it allows subclasses, such as
     # WireGuard to modify their display behaviour
     OperationalClass = Operational
 
     options = ['debug', 'create']
     required = []
     default = {
         'debug': True,
         'create': True,
     }
     definition = {
         'section': '',
         'prefixes': [],
         'vlan': False,
         'bondable': False,
         'broadcast': False,
         'bridgeable':  False,
         'eternal': '',
     }
 
     _command_get = {
         'admin_state': {
             'shellcmd': 'ip -json link show dev {ifname}',
             'format': lambda j: 'up' if 'UP' in jmespath.search('[*].flags | [0]', json.loads(j)) else 'down',
         },
         'alias': {
             'shellcmd': 'ip -json -detail link list dev {ifname}',
             'format': lambda j: jmespath.search('[*].ifalias | [0]', json.loads(j)) or '',
         },
         'mac': {
             'shellcmd': 'ip -json -detail link list dev {ifname}',
             'format': lambda j: jmespath.search('[*].address | [0]', json.loads(j)),
         },
         'min_mtu': {
             'shellcmd': 'ip -json -detail link list dev {ifname}',
             'format': lambda j: jmespath.search('[*].min_mtu | [0]', json.loads(j)),
         },
         'max_mtu': {
             'shellcmd': 'ip -json -detail link list dev {ifname}',
             'format': lambda j: jmespath.search('[*].max_mtu | [0]', json.loads(j)),
         },
         'mtu': {
             'shellcmd': 'ip -json -detail link list dev {ifname}',
             'format': lambda j: jmespath.search('[*].mtu | [0]', json.loads(j)),
         },
         'oper_state': {
             'shellcmd': 'ip -json -detail link list dev {ifname}',
             'format': lambda j: jmespath.search('[*].operstate | [0]', json.loads(j)),
         },
         'vrf': {
             'shellcmd': 'ip -json -detail link list dev {ifname}',
             'format': lambda j: jmespath.search('[?linkinfo.info_slave_kind == `vrf`].master | [0]', json.loads(j)),
         },
     }
 
     _command_set = {
         'admin_state': {
             'validate': lambda v: assert_list(v, ['up', 'down']),
             'shellcmd': 'ip link set dev {ifname} {value}',
         },
         'alias': {
             'convert': lambda name: name if name else '',
             'shellcmd': 'ip link set dev {ifname} alias "{value}"',
         },
         'bridge_port_isolation': {
             'validate': lambda v: assert_list(v, ['on', 'off']),
             'shellcmd': 'bridge link set dev {ifname} isolated {value}',
         },
         'mac': {
             'validate': assert_mac,
             'shellcmd': 'ip link set dev {ifname} address {value}',
         },
         'mtu': {
             'validate': assert_mtu,
             'shellcmd': 'ip link set dev {ifname} mtu {value}',
         },
         'netns': {
             'shellcmd': 'ip link set dev {ifname} netns {value}',
         },
         'vrf': {
             'convert': lambda v: f'master {v}' if v else 'nomaster',
             'shellcmd': 'ip link set dev {ifname} {value}',
         },
     }
 
     _sysfs_set = {
         'arp_cache_tmo': {
             'location': '/proc/sys/net/ipv4/neigh/{ifname}/base_reachable_time_ms',
         },
         'arp_filter': {
             'validate': assert_boolean,
             'location': '/proc/sys/net/ipv4/conf/{ifname}/arp_filter',
         },
         'arp_accept': {
             'validate': lambda arp: assert_range(arp,0,2),
             'location': '/proc/sys/net/ipv4/conf/{ifname}/arp_accept',
         },
         'arp_announce': {
             'validate': assert_boolean,
             'location': '/proc/sys/net/ipv4/conf/{ifname}/arp_announce',
         },
         'arp_ignore': {
             'validate': assert_boolean,
             'location': '/proc/sys/net/ipv4/conf/{ifname}/arp_ignore',
         },
         'ipv4_forwarding': {
             'validate': assert_boolean,
             'location': '/proc/sys/net/ipv4/conf/{ifname}/forwarding',
         },
         'ipv4_directed_broadcast': {
             'validate': assert_boolean,
             'location': '/proc/sys/net/ipv4/conf/{ifname}/bc_forwarding',
         },
-        'rp_filter': {
-            'validate': lambda flt: assert_range(flt,0,3),
-            'location': '/proc/sys/net/ipv4/conf/{ifname}/rp_filter',
-        },
         'ipv6_accept_ra': {
             'validate': lambda ara: assert_range(ara,0,3),
             'location': '/proc/sys/net/ipv6/conf/{ifname}/accept_ra',
         },
         'ipv6_autoconf': {
             'validate': lambda aco: assert_range(aco,0,2),
             'location': '/proc/sys/net/ipv6/conf/{ifname}/autoconf',
         },
         'ipv6_forwarding': {
             'validate': lambda fwd: assert_range(fwd,0,2),
             'location': '/proc/sys/net/ipv6/conf/{ifname}/forwarding',
         },
         'ipv6_accept_dad': {
             'validate': lambda dad: assert_range(dad,0,3),
             'location': '/proc/sys/net/ipv6/conf/{ifname}/accept_dad',
         },
         'ipv6_dad_transmits': {
             'validate': assert_positive,
             'location': '/proc/sys/net/ipv6/conf/{ifname}/dad_transmits',
         },
         'path_cost': {
             # XXX: we should set a maximum
             'validate': assert_positive,
             'location': '/sys/class/net/{ifname}/brport/path_cost',
             'errormsg': '{ifname} is not a bridge port member'
         },
         'path_priority': {
             # XXX: we should set a maximum
             'validate': assert_positive,
             'location': '/sys/class/net/{ifname}/brport/priority',
             'errormsg': '{ifname} is not a bridge port member'
         },
         'proxy_arp': {
             'validate': assert_boolean,
             'location': '/proc/sys/net/ipv4/conf/{ifname}/proxy_arp',
         },
         'proxy_arp_pvlan': {
             'validate': assert_boolean,
             'location': '/proc/sys/net/ipv4/conf/{ifname}/proxy_arp_pvlan',
         },
         # link_detect vs link_filter name weirdness
         'link_detect': {
             'validate': lambda link: assert_range(link,0,3),
             'location': '/proc/sys/net/ipv4/conf/{ifname}/link_filter',
         },
         'per_client_thread': {
             'validate': assert_boolean,
             'location': '/sys/class/net/{ifname}/threaded',
         },
     }
 
     _sysfs_get = {
         'arp_cache_tmo': {
             'location': '/proc/sys/net/ipv4/neigh/{ifname}/base_reachable_time_ms',
         },
         'arp_filter': {
             'location': '/proc/sys/net/ipv4/conf/{ifname}/arp_filter',
         },
         'arp_accept': {
             'location': '/proc/sys/net/ipv4/conf/{ifname}/arp_accept',
         },
         'arp_announce': {
             'location': '/proc/sys/net/ipv4/conf/{ifname}/arp_announce',
         },
         'arp_ignore': {
             'location': '/proc/sys/net/ipv4/conf/{ifname}/arp_ignore',
         },
         'ipv4_forwarding': {
             'location': '/proc/sys/net/ipv4/conf/{ifname}/forwarding',
         },
         'ipv4_directed_broadcast': {
             'location': '/proc/sys/net/ipv4/conf/{ifname}/bc_forwarding',
         },
-        'rp_filter': {
-            'location': '/proc/sys/net/ipv4/conf/{ifname}/rp_filter',
-        },
         'ipv6_accept_ra': {
             'location': '/proc/sys/net/ipv6/conf/{ifname}/accept_ra',
         },
         'ipv6_autoconf': {
             'location': '/proc/sys/net/ipv6/conf/{ifname}/autoconf',
         },
         'ipv6_forwarding': {
             'location': '/proc/sys/net/ipv6/conf/{ifname}/forwarding',
         },
         'ipv6_accept_dad': {
             'location': '/proc/sys/net/ipv6/conf/{ifname}/accept_dad',
         },
         'ipv6_dad_transmits': {
             'location': '/proc/sys/net/ipv6/conf/{ifname}/dad_transmits',
         },
         'proxy_arp': {
             'location': '/proc/sys/net/ipv4/conf/{ifname}/proxy_arp',
         },
         'proxy_arp_pvlan': {
             'location': '/proc/sys/net/ipv4/conf/{ifname}/proxy_arp_pvlan',
         },
         'link_detect': {
             'location': '/proc/sys/net/ipv4/conf/{ifname}/link_filter',
         },
         'per_client_thread': {
             'validate': assert_boolean,
             'location': '/sys/class/net/{ifname}/threaded',
         },
     }
 
     @classmethod
     def exists(cls, ifname):
         return os.path.exists(f'/sys/class/net/{ifname}')
 
     @classmethod
     def get_config(cls):
         """
         Some but not all interfaces require a configuration when they are added
         using iproute2. This method will provide the configuration dictionary
         used by this class.
         """
         return deepcopy(cls.default)
 
     def __init__(self, ifname, **kargs):
         """
         This is the base interface class which supports basic IP/MAC address
         operations as well as DHCP(v6). Other interface which represent e.g.
         and ethernet bridge are implemented as derived classes adding all
         additional functionality.
 
         For creation you will need to provide the interface type, otherwise
         the existing interface is used
 
         DEBUG:
         This class has embedded debugging (print) which can be enabled by
         creating the following file:
         vyos@vyos# touch /tmp/vyos.ifconfig.debug
 
         Example:
         >>> from vyos.ifconfig import Interface
         >>> i = Interface('eth0')
         """
         self.config = deepcopy(kargs)
         self.config['ifname'] = self.ifname = ifname
 
         self._admin_state_down_cnt = 0
 
         # we must have updated config before initialising the Interface
         super().__init__(**kargs)
 
         if not self.exists(ifname):
             # Any instance of Interface, such as Interface('eth0') can be used
             # safely to access the generic function in this class as 'type' is
             # unset, the class can not be created
             if not self.iftype:
                 raise Exception(f'interface "{ifname}" not found')
             self.config['type'] = self.iftype
 
             # Should an Instance of a child class (EthernetIf, DummyIf, ..)
             # be required, then create should be set to False to not accidentally create it.
             # In case a subclass does not define it, we use get to set the default to True
             if self.config.get('create',True):
                 for k in self.required:
                     if k not in kargs:
                         name = self.default['type']
                         raise ConfigError(f'missing required option {k} for {name} {ifname} creation')
 
                 self._create()
             # If we can not connect to the interface then let the caller know
             # as the class could not be correctly initialised
             else:
                 raise Exception(f'interface "{ifname}" not found!')
 
         # temporary list of assigned IP addresses
         self._addr = []
 
         self.operational = self.OperationalClass(ifname)
         self.vrrp = VRRP(ifname)
 
     def _create(self):
         cmd = 'ip link add dev {ifname} type {type}'.format(**self.config)
         self._cmd(cmd)
 
     def remove(self):
         """
         Remove interface from operating system. Removing the interface
         deconfigures all assigned IP addresses and clear possible DHCP(v6)
         client processes.
 
         Example:
         >>> from vyos.ifconfig import Interface
         >>> i = Interface('eth0')
         >>> i.remove()
         """
 
         # remove all assigned IP addresses from interface - this is a bit redundant
         # as the kernel will remove all addresses on interface deletion, but we
         # can not delete ALL interfaces, see below
         self.flush_addrs()
 
         # ---------------------------------------------------------------------
         # Any class can define an eternal regex in its definition
         # interface matching the regex will not be deleted
 
         eternal = self.definition['eternal']
         if not eternal:
             self._delete()
         elif not re.match(eternal, self.ifname):
             self._delete()
 
     def _delete(self):
         # NOTE (Improvement):
         # after interface removal no other commands should be allowed
         # to be called and instead should raise an Exception:
         cmd = 'ip link del dev {ifname}'.format(**self.config)
         return self._cmd(cmd)
 
     def _set_vrf_ct_zone(self, vrf):
         """
         Add/Remove rules in nftables to associate traffic in VRF to an
         individual conntack zone
         """
         if vrf:
             # Get routing table ID for VRF
             vrf_table_id = get_interface_config(vrf).get('linkinfo', {}).get(
                 'info_data', {}).get('table')
             # Add map element with interface and zone ID
             if vrf_table_id:
                 self._cmd(f'nft add element inet vrf_zones ct_iface_map {{ "{self.ifname}" : {vrf_table_id} }}')
         else:
             nft_del_element = f'delete element inet vrf_zones ct_iface_map {{ "{self.ifname}" }}'
             # Check if deleting is possible first to avoid raising errors
             _, err = self._popen(f'nft -c {nft_del_element}')
             if not err:
                 # Remove map element
                 self._cmd(f'nft {nft_del_element}')
 
     def get_min_mtu(self):
         """
         Get hardware minimum supported MTU
 
         Example:
         >>> from vyos.ifconfig import Interface
         >>> Interface('eth0').get_min_mtu()
         '60'
         """
         return int(self.get_interface('min_mtu'))
 
     def get_max_mtu(self):
         """
         Get hardware maximum supported MTU
 
         Example:
         >>> from vyos.ifconfig import Interface
         >>> Interface('eth0').get_max_mtu()
         '9000'
         """
         return int(self.get_interface('max_mtu'))
 
     def get_mtu(self):
         """
         Get/set interface mtu in bytes.
 
         Example:
         >>> from vyos.ifconfig import Interface
         >>> Interface('eth0').get_mtu()
         '1500'
         """
         return int(self.get_interface('mtu'))
 
     def set_mtu(self, mtu):
         """
         Get/set interface mtu in bytes.
 
         Example:
         >>> from vyos.ifconfig import Interface
         >>> Interface('eth0').set_mtu(1400)
         >>> Interface('eth0').get_mtu()
         '1400'
         """
         tmp = self.get_interface('mtu')
         if str(tmp) == mtu:
             return None
         return self.set_interface('mtu', mtu)
 
     def get_mac(self):
         """
         Get current interface MAC (Media Access Contrl) address used.
 
         Example:
         >>> from vyos.ifconfig import Interface
         >>> Interface('eth0').get_mac()
         '00:50:ab:cd:ef:00'
         """
         return self.get_interface('mac')
 
     def get_mac_synthetic(self):
         """
         Get a synthetic MAC address. This is a common method which can be called
         from derived classes to overwrite the get_mac() call in a generic way.
 
         NOTE: Tunnel interfaces have no "MAC" address by default. The content
               of the 'address' file in /sys/class/net/device contains the
               local-ip thus we generate a random MAC address instead
 
         Example:
         >>> from vyos.ifconfig import Interface
         >>> Interface('eth0').get_mac()
         '00:50:ab:cd:ef:00'
         """
         from hashlib import sha256
 
         # Get processor ID number
         cpu_id = self._cmd('sudo dmidecode -t 4 | grep ID | head -n1 | sed "s/.*ID://;s/ //g"')
 
         # XXX: T3894 - it seems not all systems have eth0 - get a list of all
         # available Ethernet interfaces on the system (without VLAN subinterfaces)
         # and then take the first one.
         all_eth_ifs = Section.interfaces('ethernet', vlan=False)
         first_mac = Interface(all_eth_ifs[0]).get_mac()
 
         sha = sha256()
         # Calculate SHA256 sum based on the CPU ID number, eth0 mac address and
         # this interface identifier - this is as predictable as an interface
         # MAC address and thus can be used in the same way
         sha.update(cpu_id.encode())
         sha.update(first_mac.encode())
         sha.update(self.ifname.encode())
         # take the most significant 48 bits from the SHA256 string
         tmp = sha.hexdigest()[:12]
         # Convert pseudo random string into EUI format which now represents a
         # MAC address
         tmp = EUI(tmp).value
         # set locally administered bit in MAC address
         tmp |= 0xf20000000000
         # convert integer to "real" MAC address representation
         mac = EUI(hex(tmp).split('x')[-1])
         # change dialect to use : as delimiter instead of -
         mac.dialect = mac_unix_expanded
         return str(mac)
 
     def set_mac(self, mac):
         """
         Set interface MAC (Media Access Contrl) address to given value.
 
         Example:
         >>> from vyos.ifconfig import Interface
         >>> Interface('eth0').set_mac('00:50:ab:cd:ef:01')
         """
 
         # If MAC is unchanged, bail out early
         if mac == self.get_mac():
             return None
 
         # MAC address can only be changed if interface is in 'down' state
         prev_state = self.get_admin_state()
         if prev_state == 'up':
             self.set_admin_state('down')
 
         self.set_interface('mac', mac)
 
         # Turn an interface to the 'up' state if it was changed to 'down' by this fucntion
         if prev_state == 'up':
             self.set_admin_state('up')
 
     def del_netns(self, netns):
         """
         Remove interface from given NETNS.
         """
 
         # If NETNS does not exist then there is nothing to delete
         if not os.path.exists(f'/run/netns/{netns}'):
             return None
 
         # As a PoC we only allow 'dummy' interfaces
         if 'dum' not in self.ifname:
             return None
 
         # Check if interface realy exists in namespace
         if get_interface_namespace(self.ifname) != None:
             self._cmd(f'ip netns exec {get_interface_namespace(self.ifname)} ip link del dev {self.ifname}')
             return
 
     def set_netns(self, netns):
         """
         Add interface from given NETNS.
 
         Example:
         >>> from vyos.ifconfig import Interface
         >>> Interface('dum0').set_netns('foo')
         """
 
         self.set_interface('netns', netns)
 
     def get_vrf(self):
         """
         Get VRF from interface
 
         Example:
         >>> from vyos.ifconfig import Interface
         >>> Interface('eth0').get_vrf()
         """
         return self.get_interface('vrf')
 
     def set_vrf(self, vrf):
         """
         Add/Remove interface from given VRF instance.
 
         Example:
         >>> from vyos.ifconfig import Interface
         >>> Interface('eth0').set_vrf('foo')
         >>> Interface('eth0').set_vrf()
         """
 
         tmp = self.get_interface('vrf')
         if tmp == vrf:
             return None
 
         self.set_interface('vrf', vrf)
         self._set_vrf_ct_zone(vrf)
 
     def set_arp_cache_tmo(self, tmo):
         """
         Set ARP cache timeout value in seconds. Internal Kernel representation
         is in milliseconds.
 
         Example:
         >>> from vyos.ifconfig import Interface
         >>> Interface('eth0').set_arp_cache_tmo(40)
         """
         tmo = str(int(tmo) * 1000)
         tmp = self.get_interface('arp_cache_tmo')
         if tmp == tmo:
             return None
         return self.set_interface('arp_cache_tmo', tmo)
 
     def _cleanup_mss_rules(self, table, ifname):
         commands = []
         results = self._cmd(f'nft -a list chain {table} VYOS_TCP_MSS').split("\n")
         for line in results:
             if f'oifname "{ifname}"' in line:
                 handle_search = re.search('handle (\d+)', line)
                 if handle_search:
                     self._cmd(f'nft delete rule {table} VYOS_TCP_MSS handle {handle_search[1]}')
 
     def set_tcp_ipv4_mss(self, mss):
         """
         Set IPv4 TCP MSS value advertised when TCP SYN packets leave this
         interface. Value is in bytes.
 
         A value of 0 will disable the MSS adjustment
 
         Example:
         >>> from vyos.ifconfig import Interface
         >>> Interface('eth0').set_tcp_ipv4_mss(1340)
         """
         self._cleanup_mss_rules('raw', self.ifname)
         nft_prefix = 'nft add rule raw VYOS_TCP_MSS'
         base_cmd = f'oifname "{self.ifname}" tcp flags & (syn|rst) == syn'
         if mss == 'clamp-mss-to-pmtu':
             self._cmd(f"{nft_prefix} '{base_cmd} tcp option maxseg size set rt mtu'")
         elif int(mss) > 0:
             low_mss = str(int(mss) + 1)
             self._cmd(f"{nft_prefix} '{base_cmd} tcp option maxseg size {low_mss}-65535 tcp option maxseg size set {mss}'")
 
     def set_tcp_ipv6_mss(self, mss):
         """
         Set IPv6 TCP MSS value advertised when TCP SYN packets leave this
         interface. Value is in bytes.
 
         A value of 0 will disable the MSS adjustment
 
         Example:
         >>> from vyos.ifconfig import Interface
         >>> Interface('eth0').set_tcp_mss(1320)
         """
         self._cleanup_mss_rules('ip6 raw', self.ifname)
         nft_prefix = 'nft add rule ip6 raw VYOS_TCP_MSS'
         base_cmd = f'oifname "{self.ifname}" tcp flags & (syn|rst) == syn'
         if mss == 'clamp-mss-to-pmtu':
             self._cmd(f"{nft_prefix} '{base_cmd} tcp option maxseg size set rt mtu'")
         elif int(mss) > 0:
             low_mss = str(int(mss) + 1)
             self._cmd(f"{nft_prefix} '{base_cmd} tcp option maxseg size {low_mss}-65535 tcp option maxseg size set {mss}'")
 
     def set_arp_filter(self, arp_filter):
         """
         Filter ARP requests
 
         1 - Allows you to have multiple network interfaces on the same
             subnet, and have the ARPs for each interface be answered
             based on whether or not the kernel would route a packet from
             the ARP'd IP out that interface (therefore you must use source
             based routing for this to work). In other words it allows control
             of which cards (usually 1) will respond to an arp request.
 
         0 - (default) The kernel can respond to arp requests with addresses
             from other interfaces. This may seem wrong but it usually makes
             sense, because it increases the chance of successful communication.
             IP addresses are owned by the complete host on Linux, not by
             particular interfaces. Only for more complex setups like load-
             balancing, does this behaviour cause problems.
         """
         tmp = self.get_interface('arp_filter')
         if tmp == arp_filter:
             return None
         return self.set_interface('arp_filter', arp_filter)
 
     def set_arp_accept(self, arp_accept):
         """
         Define behavior for gratuitous ARP frames who's IP is not
         already present in the ARP table:
         0 - don't create new entries in the ARP table
         1 - create new entries in the ARP table
 
         Both replies and requests type gratuitous arp will trigger the
         ARP table to be updated, if this setting is on.
 
         If the ARP table already contains the IP address of the
         gratuitous arp frame, the arp table will be updated regardless
         if this setting is on or off.
         """
         tmp = self.get_interface('arp_accept')
         if tmp == arp_accept:
             return None
         return self.set_interface('arp_accept', arp_accept)
 
     def set_arp_announce(self, arp_announce):
         """
         Define different restriction levels for announcing the local
         source IP address from IP packets in ARP requests sent on
         interface:
         0 - (default) Use any local address, configured on any interface
         1 - Try to avoid local addresses that are not in the target's
             subnet for this interface. This mode is useful when target
             hosts reachable via this interface require the source IP
             address in ARP requests to be part of their logical network
             configured on the receiving interface. When we generate the
             request we will check all our subnets that include the
             target IP and will preserve the source address if it is from
             such subnet.
 
         Increasing the restriction level gives more chance for
         receiving answer from the resolved target while decreasing
         the level announces more valid sender's information.
         """
         tmp = self.get_interface('arp_announce')
         if tmp == arp_announce:
             return None
         return self.set_interface('arp_announce', arp_announce)
 
     def set_arp_ignore(self, arp_ignore):
         """
         Define different modes for sending replies in response to received ARP
         requests that resolve local target IP addresses:
 
         0 - (default): reply for any local target IP address, configured
             on any interface
         1 - reply only if the target IP address is local address
             configured on the incoming interface
         """
         tmp = self.get_interface('arp_ignore')
         if tmp == arp_ignore:
             return None
         return self.set_interface('arp_ignore', arp_ignore)
 
     def set_ipv4_forwarding(self, forwarding):
         """ Configure IPv4 forwarding. """
         tmp = self.get_interface('ipv4_forwarding')
         if tmp == forwarding:
             return None
         return self.set_interface('ipv4_forwarding', forwarding)
 
     def set_ipv4_directed_broadcast(self, forwarding):
         """ Configure IPv4 directed broadcast forwarding. """
         tmp = self.get_interface('ipv4_directed_broadcast')
         if tmp == forwarding:
             return None
         return self.set_interface('ipv4_directed_broadcast', forwarding)
 
-    def set_ipv4_source_validation(self, value):
-        """
-        Help prevent attacks used by Spoofing IP Addresses. Reverse path
-        filtering is a Kernel feature that, when enabled, is designed to ensure
-        packets that are not routable to be dropped. The easiest example of this
-        would be and IP Address of the range 10.0.0.0/8, a private IP Address,
-        being received on the Internet facing interface of the router.
+    def _cleanup_ipv4_source_validation_rules(self, ifname):
+        results = self._cmd(f'nft -a list chain ip raw vyos_rpfilter').split("\n")
+        for line in results:
+            if f'iifname "{ifname}"' in line:
+                handle_search = re.search('handle (\d+)', line)
+                if handle_search:
+                    self._cmd(f'nft delete rule ip raw vyos_rpfilter handle {handle_search[1]}')
 
-        As per RFC3074.
+    def set_ipv4_source_validation(self, mode):
         """
-        if value == 'strict':
-            value = 1
-        elif value == 'loose':
-            value = 2
-        else:
-            value = 0
-
-        all_rp_filter = int(read_file('/proc/sys/net/ipv4/conf/all/rp_filter'))
-        if all_rp_filter > value:
-            global_setting = 'disable'
-            if   all_rp_filter == 1: global_setting = 'strict'
-            elif all_rp_filter == 2: global_setting = 'loose'
-
-            from vyos.base import Warning
-            Warning(f'Global source-validation is set to "{global_setting}", this '\
-                    f'overrides per interface setting on "{self.ifname}"!')
+        Set IPv4 reverse path validation
 
-        tmp = self.get_interface('rp_filter')
-        if int(tmp) == value:
-            return None
-        return self.set_interface('rp_filter', value)
+        Example:
+        >>> from vyos.ifconfig import Interface
+        >>> Interface('eth0').set_ipv4_source_validation('strict')
+        """
+        self._cleanup_ipv4_source_validation_rules(self.ifname)
+        nft_prefix = f'nft insert rule ip raw vyos_rpfilter iifname "{self.ifname}"'
+        if mode in ['strict', 'loose']:
+            self._cmd(f"{nft_prefix} counter return")
+        if mode == 'strict':
+            self._cmd(f"{nft_prefix} fib saddr . iif oif 0 counter drop")
+        elif mode == 'loose':
+            self._cmd(f"{nft_prefix} fib saddr oif 0 counter drop")
 
     def _cleanup_ipv6_source_validation_rules(self, ifname):
-        commands = []
         results = self._cmd(f'nft -a list chain ip6 raw vyos_rpfilter').split("\n")
         for line in results:
             if f'iifname "{ifname}"' in line:
                 handle_search = re.search('handle (\d+)', line)
                 if handle_search:
                     self._cmd(f'nft delete rule ip6 raw vyos_rpfilter handle {handle_search[1]}')
 
     def set_ipv6_source_validation(self, mode):
         """
         Set IPv6 reverse path validation
 
         Example:
         >>> from vyos.ifconfig import Interface
         >>> Interface('eth0').set_ipv6_source_validation('strict')
         """
         self._cleanup_ipv6_source_validation_rules(self.ifname)
-        nft_prefix = f'nft add rule ip6 raw vyos_rpfilter iifname "{self.ifname}"'
+        nft_prefix = f'nft insert rule ip6 raw vyos_rpfilter iifname "{self.ifname}"'
+        if mode in ['strict', 'loose']:
+            self._cmd(f"{nft_prefix} counter return")
         if mode == 'strict':
             self._cmd(f"{nft_prefix} fib saddr . iif oif 0 counter drop")
         elif mode == 'loose':
             self._cmd(f"{nft_prefix} fib saddr oif 0 counter drop")
 
     def set_ipv6_accept_ra(self, accept_ra):
         """
         Accept Router Advertisements; autoconfigure using them.
 
         It also determines whether or not to transmit Router Solicitations.
         If and only if the functional setting is to accept Router
         Advertisements, Router Solicitations will be transmitted.
 
         0 - Do not accept Router Advertisements.
         1 - (default) Accept Router Advertisements if forwarding is disabled.
         2 - Overrule forwarding behaviour. Accept Router Advertisements even if
             forwarding is enabled.
         """
         tmp = self.get_interface('ipv6_accept_ra')
         if tmp == accept_ra:
             return None
         return self.set_interface('ipv6_accept_ra', accept_ra)
 
     def set_ipv6_autoconf(self, autoconf):
         """
         Autoconfigure addresses using Prefix Information in Router
         Advertisements.
         """
         tmp = self.get_interface('ipv6_autoconf')
         if tmp == autoconf:
             return None
         return self.set_interface('ipv6_autoconf', autoconf)
 
     def add_ipv6_eui64_address(self, prefix):
         """
         Extended Unique Identifier (EUI), as per RFC2373, allows a host to
         assign itself a unique IPv6 address based on a given IPv6 prefix.
 
         Calculate the EUI64 from the interface's MAC, then assign it
         with the given prefix to the interface.
         """
         # T2863: only add a link-local IPv6 address if the interface returns
         # a MAC address. This is not the case on e.g. WireGuard interfaces.
         mac = self.get_mac()
         if mac:
             eui64 = mac2eui64(mac, prefix)
             prefixlen = prefix.split('/')[1]
             self.add_addr(f'{eui64}/{prefixlen}')
 
     def del_ipv6_eui64_address(self, prefix):
         """
         Delete the address based on the interface's MAC-based EUI64
         combined with the prefix address.
         """
         if is_ipv6(prefix):
             eui64 = mac2eui64(self.get_mac(), prefix)
             prefixlen = prefix.split('/')[1]
             self.del_addr(f'{eui64}/{prefixlen}')
 
     def set_ipv6_forwarding(self, forwarding):
         """
         Configure IPv6 interface-specific Host/Router behaviour.
 
         False:
 
         By default, Host behaviour is assumed.  This means:
 
         1. IsRouter flag is not set in Neighbour Advertisements.
         2. If accept_ra is TRUE (default), transmit Router
            Solicitations.
         3. If accept_ra is TRUE (default), accept Router
            Advertisements (and do autoconfiguration).
         4. If accept_redirects is TRUE (default), accept Redirects.
 
         True:
 
         If local forwarding is enabled, Router behaviour is assumed.
         This means exactly the reverse from the above:
 
         1. IsRouter flag is set in Neighbour Advertisements.
         2. Router Solicitations are not sent unless accept_ra is 2.
         3. Router Advertisements are ignored unless accept_ra is 2.
         4. Redirects are ignored.
         """
         tmp = self.get_interface('ipv6_forwarding')
         if tmp == forwarding:
             return None
         return self.set_interface('ipv6_forwarding', forwarding)
 
     def set_ipv6_dad_accept(self, dad):
         """Whether to accept DAD (Duplicate Address Detection)"""
         tmp = self.get_interface('ipv6_accept_dad')
         if tmp == dad:
             return None
         return self.set_interface('ipv6_accept_dad', dad)
 
     def set_ipv6_dad_messages(self, dad):
         """
         The amount of Duplicate Address Detection probes to send.
         Default: 1
         """
         tmp = self.get_interface('ipv6_dad_transmits')
         if tmp == dad:
             return None
         return self.set_interface('ipv6_dad_transmits', dad)
 
     def set_link_detect(self, link_filter):
         """
         Configure kernel response in packets received on interfaces that are 'down'
 
         0 - Allow packets to be received for the address on this interface
             even if interface is disabled or no carrier.
 
         1 - Ignore packets received if interface associated with the incoming
             address is down.
 
         2 - Ignore packets received if interface associated with the incoming
             address is down or has no carrier.
 
         Default value is 0. Note that some distributions enable it in startup
         scripts.
 
         Example:
         >>> from vyos.ifconfig import Interface
         >>> Interface('eth0').set_link_detect(1)
         """
         tmp = self.get_interface('link_detect')
         if tmp == link_filter:
             return None
         return self.set_interface('link_detect', link_filter)
 
     def get_alias(self):
         """
         Get interface alias name used by e.g. SNMP
 
         Example:
         >>> Interface('eth0').get_alias()
         'interface description as set by user'
         """
         return self.get_interface('alias')
 
     def set_alias(self, ifalias=''):
         """
         Set interface alias name used by e.g. SNMP
 
         Example:
         >>> from vyos.ifconfig import Interface
         >>> Interface('eth0').set_alias('VyOS upstream interface')
 
         to clear alias e.g. delete it use:
 
         >>> Interface('eth0').set_ifalias('')
         """
         tmp = self.get_interface('alias')
         if tmp == ifalias:
             return None
         self.set_interface('alias', ifalias)
 
     def get_admin_state(self):
         """
         Get interface administrative state. Function will return 'up' or 'down'
 
         Example:
         >>> from vyos.ifconfig import Interface
         >>> Interface('eth0').get_admin_state()
         'up'
         """
         return self.get_interface('admin_state')
 
     def set_admin_state(self, state):
         """
         Set interface administrative state to be 'up' or 'down'
 
         Example:
         >>> from vyos.ifconfig import Interface
         >>> Interface('eth0').set_admin_state('down')
         >>> Interface('eth0').get_admin_state()
         'down'
         """
         if state == 'up':
             self._admin_state_down_cnt -= 1
             if self._admin_state_down_cnt < 1:
                 return self.set_interface('admin_state', state)
         else:
             self._admin_state_down_cnt += 1
             return self.set_interface('admin_state', state)
 
     def set_path_cost(self, cost):
         """
         Set interface path cost, only relevant for STP enabled interfaces
 
         Example:
 
         >>> from vyos.ifconfig import Interface
         >>> Interface('eth0').set_path_cost(4)
         """
         self.set_interface('path_cost', cost)
 
     def set_path_priority(self, priority):
         """
         Set interface path priority, only relevant for STP enabled interfaces
 
         Example:
 
         >>> from vyos.ifconfig import Interface
         >>> Interface('eth0').set_path_priority(4)
         """
         self.set_interface('path_priority', priority)
 
     def set_port_isolation(self, on_or_off):
         """
         Controls whether a given port will be isolated, which means it will be
         able to communicate with non-isolated ports only. By default this flag
         is off.
 
         Use enable=1 to enable or enable=0 to disable
 
         Example:
         >>> from vyos.ifconfig import Interface
         >>> Interface('eth1').set_port_isolation('on')
         """
         self.set_interface('bridge_port_isolation', on_or_off)
 
     def set_proxy_arp(self, enable):
         """
         Set per interface proxy ARP configuration
 
         Example:
         >>> from vyos.ifconfig import Interface
         >>> Interface('eth0').set_proxy_arp(1)
         """
         tmp = self.get_interface('proxy_arp')
         if tmp == enable:
             return None
         self.set_interface('proxy_arp', enable)
 
     def set_proxy_arp_pvlan(self, enable):
         """
         Private VLAN proxy arp.
         Basically allow proxy arp replies back to the same interface
         (from which the ARP request/solicitation was received).
 
         This is done to support (ethernet) switch features, like RFC
         3069, where the individual ports are NOT allowed to
         communicate with each other, but they are allowed to talk to
         the upstream router.  As described in RFC 3069, it is possible
         to allow these hosts to communicate through the upstream
         router by proxy_arp'ing. Don't need to be used together with
         proxy_arp.
 
         This technology is known by different names:
         In RFC 3069 it is called VLAN Aggregation.
         Cisco and Allied Telesyn call it Private VLAN.
         Hewlett-Packard call it Source-Port filtering or port-isolation.
         Ericsson call it MAC-Forced Forwarding (RFC Draft).
 
         Example:
         >>> from vyos.ifconfig import Interface
         >>> Interface('eth0').set_proxy_arp_pvlan(1)
         """
         tmp = self.get_interface('proxy_arp_pvlan')
         if tmp == enable:
             return None
         self.set_interface('proxy_arp_pvlan', enable)
 
     def get_addr_v4(self):
         """
         Retrieve assigned IPv4 addresses from given interface.
         This is done using the netifaces and ipaddress python modules.
 
         Example:
         >>> from vyos.ifconfig import Interface
         >>> Interface('eth0').get_addr_v4()
         ['172.16.33.30/24']
         """
         ipv4 = []
         if AF_INET in ifaddresses(self.config['ifname']):
             for v4_addr in ifaddresses(self.config['ifname'])[AF_INET]:
                 # we need to manually assemble a list of IPv4 address/prefix
                 prefix = '/' + \
                     str(IPv4Network('0.0.0.0/' + v4_addr['netmask']).prefixlen)
                 ipv4.append(v4_addr['addr'] + prefix)
         return ipv4
 
     def get_addr_v6(self):
         """
         Retrieve assigned IPv6 addresses from given interface.
         This is done using the netifaces and ipaddress python modules.
 
         Example:
         >>> from vyos.ifconfig import Interface
         >>> Interface('eth0').get_addr_v6()
         ['fe80::20c:29ff:fe11:a174/64']
         """
         ipv6 = []
         if AF_INET6 in ifaddresses(self.config['ifname']):
             for v6_addr in ifaddresses(self.config['ifname'])[AF_INET6]:
                 # Note that currently expanded netmasks are not supported. That means
                 # 2001:db00::0/24 is a valid argument while 2001:db00::0/ffff:ff00:: not.
                 # see https://docs.python.org/3/library/ipaddress.html
                 prefix = '/' + v6_addr['netmask'].split('/')[-1]
 
                 # we alsoneed to remove the interface suffix on link local
                 # addresses
                 v6_addr['addr'] = v6_addr['addr'].split('%')[0]
                 ipv6.append(v6_addr['addr'] + prefix)
         return ipv6
 
     def get_addr(self):
         """
         Retrieve assigned IPv4 and IPv6 addresses from given interface.
 
         Example:
         >>> from vyos.ifconfig import Interface
         >>> Interface('eth0').get_addr()
         ['172.16.33.30/24', 'fe80::20c:29ff:fe11:a174/64']
         """
         return self.get_addr_v4() + self.get_addr_v6()
 
     def add_addr(self, addr):
         """
         Add IP(v6) address to interface. Address is only added if it is not
         already assigned to that interface. Address format must be validated
         and compressed/normalized before calling this function.
 
         addr: can be an IPv4 address, IPv6 address, dhcp or dhcpv6!
               IPv4: add IPv4 address to interface
               IPv6: add IPv6 address to interface
               dhcp: start dhclient (IPv4) on interface
               dhcpv6: start WIDE DHCPv6 (IPv6) on interface
 
         Returns False if address is already assigned and wasn't re-added.
         Example:
         >>> from vyos.ifconfig import Interface
         >>> j = Interface('eth0')
         >>> j.add_addr('192.0.2.1/24')
         >>> j.add_addr('2001:db8::ffff/64')
         >>> j.get_addr()
         ['192.0.2.1/24', '2001:db8::ffff/64']
         """
         # XXX: normalize/compress with ipaddress if calling functions don't?
         # is subnet mask always passed, and in the same way?
 
         # do not add same address twice
         if addr in self._addr:
             return False
 
         # add to interface
         if addr == 'dhcp':
             self.set_dhcp(True)
         elif addr == 'dhcpv6':
             self.set_dhcpv6(True)
         elif not is_intf_addr_assigned(self.ifname, addr):
             tmp = f'ip addr add {addr} dev {self.ifname}'
             # Add broadcast address for IPv4
             if is_ipv4(addr): tmp += ' brd +'
 
             self._cmd(tmp)
         else:
             return False
 
         # add to cache
         self._addr.append(addr)
 
         return True
 
     def del_addr(self, addr):
         """
         Delete IP(v6) address from interface. Address is only deleted if it is
         assigned to that interface. Address format must be exactly the same as
         was used when adding the address.
 
         addr: can be an IPv4 address, IPv6 address, dhcp or dhcpv6!
               IPv4: delete IPv4 address from interface
               IPv6: delete IPv6 address from interface
               dhcp: stop dhclient (IPv4) on interface
               dhcpv6: stop dhclient (IPv6) on interface
 
         Returns False if address isn't already assigned and wasn't deleted.
         Example:
         >>> from vyos.ifconfig import Interface
         >>> j = Interface('eth0')
         >>> j.add_addr('2001:db8::ffff/64')
         >>> j.add_addr('192.0.2.1/24')
         >>> j.get_addr()
         ['192.0.2.1/24', '2001:db8::ffff/64']
         >>> j.del_addr('192.0.2.1/24')
         >>> j.get_addr()
         ['2001:db8::ffff/64']
         """
         if not addr:
             raise ValueError()
 
         # remove from interface
         if addr == 'dhcp':
             self.set_dhcp(False)
         elif addr == 'dhcpv6':
             self.set_dhcpv6(False)
         elif is_intf_addr_assigned(self.ifname, addr):
             self._cmd(f'ip addr del "{addr}" dev "{self.ifname}"')
         else:
             return False
 
         # remove from cache
         if addr in self._addr:
             self._addr.remove(addr)
 
         return True
 
     def flush_addrs(self):
         """
         Flush all addresses from an interface, including DHCP.
 
         Will raise an exception on error.
         """
         # stop DHCP(v6) if running
         self.set_dhcp(False)
         self.set_dhcpv6(False)
 
         # flush all addresses
         self._cmd(f'ip addr flush dev "{self.ifname}"')
 
     def add_to_bridge(self, bridge_dict):
         """
         Adds the interface to the bridge with the passed port config.
 
         Returns False if bridge doesn't exist.
         """
 
         # drop all interface addresses first
         self.flush_addrs()
 
         ifname = self.ifname
 
         for bridge, bridge_config in bridge_dict.items():
             # add interface to bridge - use Section.klass to get BridgeIf class
             Section.klass(bridge)(bridge, create=True).add_port(self.ifname)
 
             # set bridge port path cost
             if 'cost' in bridge_config:
                 self.set_path_cost(bridge_config['cost'])
 
             # set bridge port path priority
             if 'priority' in bridge_config:
                 self.set_path_cost(bridge_config['priority'])
 
             bridge_vlan_filter = Section.klass(bridge)(bridge, create=True).get_vlan_filter()
 
             if int(bridge_vlan_filter):
                 cur_vlan_ids = get_vlan_ids(ifname)
                 add_vlan = []
                 native_vlan_id = None
                 allowed_vlan_ids= []
 
                 if 'native_vlan' in bridge_config:
                     vlan_id = bridge_config['native_vlan']
                     add_vlan.append(vlan_id)
                     native_vlan_id = vlan_id
 
                 if 'allowed_vlan' in bridge_config:
                     for vlan in bridge_config['allowed_vlan']:
                         vlan_range = vlan.split('-')
                         if len(vlan_range) == 2:
                             for vlan_add in range(int(vlan_range[0]),int(vlan_range[1]) + 1):
                                 add_vlan.append(str(vlan_add))
                                 allowed_vlan_ids.append(str(vlan_add))
                         else:
                             add_vlan.append(vlan)
                             allowed_vlan_ids.append(vlan)
 
                 # Remove redundant VLANs from the system
                 for vlan in list_diff(cur_vlan_ids, add_vlan):
                     cmd = f'bridge vlan del dev {ifname} vid {vlan} master'
                     self._cmd(cmd)
 
                 for vlan in allowed_vlan_ids:
                     cmd = f'bridge vlan add dev {ifname} vid {vlan} master'
                     self._cmd(cmd)
                 # Setting native VLAN to system
                 if native_vlan_id:
                     cmd = f'bridge vlan add dev {ifname} vid {native_vlan_id} pvid untagged master'
                     self._cmd(cmd)
 
     def set_dhcp(self, enable):
         """
         Enable/Disable DHCP client on a given interface.
         """
         if enable not in [True, False]:
             raise ValueError()
 
         ifname = self.ifname
         config_base = directories['isc_dhclient_dir'] + '/dhclient'
         dhclient_config_file = f'{config_base}_{ifname}.conf'
         dhclient_lease_file = f'{config_base}_{ifname}.leases'
         systemd_override_file = f'/run/systemd/system/dhclient@{ifname}.service.d/10-override.conf'
         systemd_service = f'dhclient@{ifname}.service'
 
         # Rendered client configuration files require the apsolute config path
         self.config['isc_dhclient_dir'] = directories['isc_dhclient_dir']
 
         # 'up' check is mandatory b/c even if the interface is A/D, as soon as
         # the DHCP client is started the interface will be placed in u/u state.
         # This is not what we intended to do when disabling an interface.
         if enable and 'disable' not in self.config:
             if dict_search('dhcp_options.host_name', self.config) == None:
                 # read configured system hostname.
                 # maybe change to vyos hostd client ???
                 hostname = 'vyos'
                 with open('/etc/hostname', 'r') as f:
                     hostname = f.read().rstrip('\n')
                     tmp = {'dhcp_options' : { 'host_name' : hostname}}
                     self.config = dict_merge(tmp, self.config)
 
             render(systemd_override_file, 'dhcp-client/override.conf.j2', self.config)
             render(dhclient_config_file, 'dhcp-client/ipv4.j2', self.config)
 
             # Reload systemd unit definitons as some options are dynamically generated
             self._cmd('systemctl daemon-reload')
 
             # When the DHCP client is restarted a brief outage will occur, as
             # the old lease is released a new one is acquired (T4203). We will
             # only restart DHCP client if it's option changed, or if it's not
             # running, but it should be running (e.g. on system startup)
             if 'dhcp_options_changed' in self.config or not is_systemd_service_active(systemd_service):
                 return self._cmd(f'systemctl restart {systemd_service}')
         else:
             if is_systemd_service_active(systemd_service):
                 self._cmd(f'systemctl stop {systemd_service}')
             # cleanup old config files
             for file in [dhclient_config_file, systemd_override_file, dhclient_lease_file]:
                 if os.path.isfile(file):
                     os.remove(file)
 
         return None
 
     def set_dhcpv6(self, enable):
         """
         Enable/Disable DHCPv6 client on a given interface.
         """
         if enable not in [True, False]:
             raise ValueError()
 
         ifname = self.ifname
         config_base = directories['dhcp6_client_dir']
         config_file = f'{config_base}/dhcp6c.{ifname}.conf'
         systemd_override_file = f'/run/systemd/system/dhcp6c@{ifname}.service.d/10-override.conf'
         systemd_service = f'dhcp6c@{ifname}.service'
 
         # Rendered client configuration files require the apsolute config path
         self.config['dhcp6_client_dir'] = directories['dhcp6_client_dir']
 
         if enable and 'disable' not in self.config:
             render(systemd_override_file, 'dhcp-client/ipv6.override.conf.j2', self.config)
             render(config_file, 'dhcp-client/ipv6.j2', self.config)
 
             # Reload systemd unit definitons as some options are dynamically generated
             self._cmd('systemctl daemon-reload')
 
             # We must ignore any return codes. This is required to enable
             # DHCPv6-PD for interfaces which are yet not up and running.
             return self._popen(f'systemctl restart {systemd_service}')
         else:
             if is_systemd_service_active(systemd_service):
                 self._cmd(f'systemctl stop {systemd_service}')
             if os.path.isfile(config_file):
                 os.remove(config_file)
 
         return None
 
     def set_mirror_redirect(self):
         # Please refer to the document for details
         #   - https://man7.org/linux/man-pages/man8/tc.8.html
         #   - https://man7.org/linux/man-pages/man8/tc-mirred.8.html
         # Depening if we are the source or the target interface of the port
         # mirror we need to setup some variables.
         source_if = self.config['ifname']
 
         mirror_config = None
         if 'mirror' in self.config:
             mirror_config = self.config['mirror']
         if 'is_mirror_intf' in self.config:
             source_if = next(iter(self.config['is_mirror_intf']))
             mirror_config = self.config['is_mirror_intf'][source_if].get('mirror', None)
 
         redirect_config = None
 
         # clear existing ingess - ignore errors (e.g. "Error: Cannot find specified
         # qdisc on specified device") - we simply cleanup all stuff here
         if not 'traffic_policy' in self.config:
             self._popen(f'tc qdisc del dev {source_if} parent ffff: 2>/dev/null');
             self._popen(f'tc qdisc del dev {source_if} parent 1: 2>/dev/null');
 
         # Apply interface mirror policy
         if mirror_config:
             for direction, target_if in mirror_config.items():
                 if direction == 'ingress':
                     handle = 'ffff: ingress'
                     parent = 'ffff:'
                 elif direction == 'egress':
                     handle = '1: root prio'
                     parent = '1:'
 
                 # Mirror egress traffic
                 mirror_cmd  = f'tc qdisc add dev {source_if} handle {handle}; '
                 # Export the mirrored traffic to the interface
                 mirror_cmd += f'tc filter add dev {source_if} parent {parent} protocol '\
                               f'all prio 10 u32 match u32 0 0 flowid 1:1 action mirred '\
                               f'egress mirror dev {target_if}'
                 _, err = self._popen(mirror_cmd)
                 if err: print('tc qdisc(filter for mirror port failed')
 
         # Apply interface traffic redirection policy
         elif 'redirect' in self.config:
             _, err = self._popen(f'tc qdisc add dev {source_if} handle ffff: ingress')
             if err: print(f'tc qdisc add for redirect failed!')
 
             target_if = self.config['redirect']
             _, err = self._popen(f'tc filter add dev {source_if} parent ffff: protocol '\
                                  f'all prio 10 u32 match u32 0 0 flowid 1:1 action mirred '\
                                  f'egress redirect dev {target_if}')
             if err: print('tc filter add for redirect failed')
 
     def set_per_client_thread(self, enable):
         """
         Per-device control to enable/disable the threaded mode for all the napi
         instances of the given network device, without the need for a device up/down.
 
         User sets it to 1 or 0 to enable or disable threaded mode.
 
         Example:
         >>> from vyos.ifconfig import Interface
         >>> Interface('wg1').set_per_client_thread(1)
         """
         # In the case of a "virtual" interface like wireguard, the sysfs
         # node is only created once there is a peer configured. We can now
         # add a verify() code-path for this or make this dynamic without
         # nagging the user
         tmp = self._sysfs_get['per_client_thread']['location']
         if not os.path.exists(tmp):
             return None
 
         tmp = self.get_interface('per_client_thread')
         if tmp == enable:
             return None
         self.set_interface('per_client_thread', enable)
 
     def update(self, config):
         """ General helper function which works on a dictionary retrived by
         get_config_dict(). It's main intention is to consolidate the scattered
         interface setup code and provide a single point of entry when workin
         on any interface. """
 
         if self.debug:
             import pprint
             pprint.pprint(config)
 
         # Cache the configuration - it will be reused inside e.g. DHCP handler
         # XXX: maybe pass the option via __init__ in the future and rename this
         # method to apply()?
         self.config = config
 
         # Change interface MAC address - re-set to real hardware address (hw-id)
         # if custom mac is removed. Skip if bond member.
         if 'is_bond_member' not in config:
             mac = config.get('hw_id')
             if 'mac' in config:
                 mac = config.get('mac')
             if mac:
                 self.set_mac(mac)
 
         # If interface is connected to NETNS we don't have to check all other
         # settings like MTU/IPv6/sysctl values, etc.
         # Since the interface is pushed onto a separate logical stack
         # Configure NETNS
         if dict_search('netns', config) != None:
             self.set_netns(config.get('netns', ''))
             return
         else:
             self.del_netns(config.get('netns', ''))
 
         # Update interface description
         self.set_alias(config.get('description', ''))
 
         # Ignore link state changes
         value = '2' if 'disable_link_detect' in config else '1'
         self.set_link_detect(value)
 
         # Configure assigned interface IP addresses. No longer
         # configured addresses will be removed first
         new_addr = config.get('address', [])
 
         # always ensure DHCP client is stopped (when not configured explicitly)
         if 'dhcp' not in new_addr:
             self.del_addr('dhcp')
 
         # always ensure DHCPv6 client is stopped (when not configured as client
         # for IPv6 address or prefix delegation)
         dhcpv6pd = dict_search('dhcpv6_options.pd', config)
         dhcpv6pd = dhcpv6pd != None and len(dhcpv6pd) != 0
         if 'dhcpv6' not in new_addr and not dhcpv6pd:
             self.del_addr('dhcpv6')
 
         # determine IP addresses which are assigned to the interface and build a
         # list of addresses which are no longer in the dict so they can be removed
         if 'address_old' in config:
             for addr in list_diff(config['address_old'], new_addr):
                 # we will delete all interface specific IP addresses if they are not
                 # explicitly configured on the CLI
                 if is_ipv6_link_local(addr):
                     eui64 = mac2eui64(self.get_mac(), link_local_prefix)
                     if addr != f'{eui64}/64':
                         self.del_addr(addr)
                 else:
                     self.del_addr(addr)
 
         # start DHCPv6 client when only PD was configured
         if dhcpv6pd:
             self.set_dhcpv6(True)
 
         # XXX: Bind interface to given VRF or unbind it if vrf is not set. Unbinding
         # will call 'ip link set dev eth0 nomaster' which will also drop the
         # interface out of any bridge or bond - thus this is checked before.
         if 'is_bond_member' in config:
             bond_if = next(iter(config['is_bond_member']))
             tmp = get_interface_config(config['ifname'])
             if 'master' in tmp and tmp['master'] != bond_if:
                 self.set_vrf('')
 
         elif 'is_bridge_member' in config:
             bridge_if = next(iter(config['is_bridge_member']))
             tmp = get_interface_config(config['ifname'])
             if 'master' in tmp and tmp['master'] != bridge_if:
                 self.set_vrf('')
 
         else:
             self.set_vrf(config.get('vrf', ''))
 
         # Add this section after vrf T4331
         for addr in new_addr:
             self.add_addr(addr)
 
         # Configure MSS value for IPv4 TCP connections
         tmp = dict_search('ip.adjust_mss', config)
         value = tmp if (tmp != None) else '0'
         self.set_tcp_ipv4_mss(value)
 
         # Configure ARP cache timeout in milliseconds - has default value
         tmp = dict_search('ip.arp_cache_timeout', config)
         value = tmp if (tmp != None) else '30'
         self.set_arp_cache_tmo(value)
 
         # Configure ARP filter configuration
         tmp = dict_search('ip.disable_arp_filter', config)
         value = '0' if (tmp != None) else '1'
         self.set_arp_filter(value)
 
         # Configure ARP accept
         tmp = dict_search('ip.enable_arp_accept', config)
         value = '1' if (tmp != None) else '0'
         self.set_arp_accept(value)
 
         # Configure ARP announce
         tmp = dict_search('ip.enable_arp_announce', config)
         value = '1' if (tmp != None) else '0'
         self.set_arp_announce(value)
 
         # Configure ARP ignore
         tmp = dict_search('ip.enable_arp_ignore', config)
         value = '1' if (tmp != None) else '0'
         self.set_arp_ignore(value)
 
         # Enable proxy-arp on this interface
         tmp = dict_search('ip.enable_proxy_arp', config)
         value = '1' if (tmp != None) else '0'
         self.set_proxy_arp(value)
 
         # Enable private VLAN proxy ARP on this interface
         tmp = dict_search('ip.proxy_arp_pvlan', config)
         value = '1' if (tmp != None) else '0'
         self.set_proxy_arp_pvlan(value)
 
         # IPv4 forwarding
         tmp = dict_search('ip.disable_forwarding', config)
         value = '0' if (tmp != None) else '1'
         self.set_ipv4_forwarding(value)
 
         # IPv4 directed broadcast forwarding
         tmp = dict_search('ip.enable_directed_broadcast', config)
         value = '1' if (tmp != None) else '0'
         self.set_ipv4_directed_broadcast(value)
 
         # IPv4 source-validation
         tmp = dict_search('ip.source_validation', config)
         value = tmp if (tmp != None) else '0'
         self.set_ipv4_source_validation(value)
 
         # IPv6 source-validation
         tmp = dict_search('ipv6.source_validation', config)
         value = tmp if (tmp != None) else '0'
         self.set_ipv6_source_validation(value)
 
         # MTU - Maximum Transfer Unit has a default value. It must ALWAYS be set
         # before mangling any IPv6 option. If MTU is less then 1280 IPv6 will be
         # automatically disabled by the kernel. Also MTU must be increased before
         # configuring any IPv6 address on the interface.
         if 'mtu' in config and dict_search('dhcp_options.mtu', config) == None:
             self.set_mtu(config.get('mtu'))
 
         # Configure MSS value for IPv6 TCP connections
         tmp = dict_search('ipv6.adjust_mss', config)
         value = tmp if (tmp != None) else '0'
         self.set_tcp_ipv6_mss(value)
 
         # IPv6 forwarding
         tmp = dict_search('ipv6.disable_forwarding', config)
         value = '0' if (tmp != None) else '1'
         self.set_ipv6_forwarding(value)
 
         # IPv6 router advertisements
         tmp = dict_search('ipv6.address.autoconf', config)
         value = '2' if (tmp != None) else '1'
         if 'dhcpv6' in new_addr:
             value = '2'
         self.set_ipv6_accept_ra(value)
 
         # IPv6 address autoconfiguration
         tmp = dict_search('ipv6.address.autoconf', config)
         value = '1' if (tmp != None) else '0'
         self.set_ipv6_autoconf(value)
 
         # Whether to accept IPv6 DAD (Duplicate Address Detection) packets
         tmp = dict_search('ipv6.accept_dad', config)
         # Not all interface types got this CLI option, but if they do, there
         # is an XML defaultValue available
         if (tmp != None): self.set_ipv6_dad_accept(tmp)
 
         # IPv6 DAD tries
         tmp = dict_search('ipv6.dup_addr_detect_transmits', config)
         # Not all interface types got this CLI option, but if they do, there
         # is an XML defaultValue available
         if (tmp != None): self.set_ipv6_dad_messages(tmp)
 
         # Delete old IPv6 EUI64 addresses before changing MAC
         for addr in (dict_search('ipv6.address.eui64_old', config) or []):
             self.del_ipv6_eui64_address(addr)
 
         # Manage IPv6 link-local addresses
         if dict_search('ipv6.address.no_default_link_local', config) != None:
             self.del_ipv6_eui64_address(link_local_prefix)
         else:
             self.add_ipv6_eui64_address(link_local_prefix)
 
         # Add IPv6 EUI-based addresses
         tmp = dict_search('ipv6.address.eui64', config)
         if tmp:
             for addr in tmp:
                 self.add_ipv6_eui64_address(addr)
 
         # re-add ourselves to any bridge we might have fallen out of
         if 'is_bridge_member' in config:
             tmp = config.get('is_bridge_member')
             self.add_to_bridge(tmp)
 
         # configure interface mirror or redirection target
         self.set_mirror_redirect()
 
         # enable/disable NAPI threading mode
         tmp = dict_search('per_client_thread', config)
         value = '1' if (tmp != None) else '0'
         self.set_per_client_thread(value)
 
         # Enable/Disable of an interface must always be done at the end of the
         # derived class to make use of the ref-counting set_admin_state()
         # function. We will only enable the interface if 'up' was called as
         # often as 'down'. This is required by some interface implementations
         # as certain parameters can only be changed when the interface is
         # in admin-down state. This ensures the link does not flap during
         # reconfiguration.
         state = 'down' if 'disable' in config else 'up'
         self.set_admin_state(state)
 
         # remove no longer required 802.1ad (Q-in-Q VLANs)
         ifname = config['ifname']
         for vif_s_id in config.get('vif_s_remove', {}):
             vif_s_ifname = f'{ifname}.{vif_s_id}'
             VLANIf(vif_s_ifname).remove()
 
         # create/update 802.1ad (Q-in-Q VLANs)
         for vif_s_id, vif_s_config in config.get('vif_s', {}).items():
             tmp = deepcopy(VLANIf.get_config())
             tmp['protocol'] = vif_s_config['protocol']
             tmp['source_interface'] = ifname
             tmp['vlan_id'] = vif_s_id
 
             # It is not possible to change the VLAN encapsulation protocol
             # "on-the-fly". For this "quirk" we need to actively delete and
             # re-create the VIF-S interface.
             vif_s_ifname = f'{ifname}.{vif_s_id}'
             if self.exists(vif_s_ifname):
                 cur_cfg = get_interface_config(vif_s_ifname)
                 protocol = dict_search('linkinfo.info_data.protocol', cur_cfg).lower()
                 if protocol != vif_s_config['protocol']:
                     VLANIf(vif_s_ifname).remove()
 
             s_vlan = VLANIf(vif_s_ifname, **tmp)
             s_vlan.update(vif_s_config)
 
             # remove no longer required client VLAN (vif-c)
             for vif_c_id in vif_s_config.get('vif_c_remove', {}):
                 vif_c_ifname = f'{vif_s_ifname}.{vif_c_id}'
                 VLANIf(vif_c_ifname).remove()
 
             # create/update client VLAN (vif-c) interface
             for vif_c_id, vif_c_config in vif_s_config.get('vif_c', {}).items():
                 tmp = deepcopy(VLANIf.get_config())
                 tmp['source_interface'] = vif_s_ifname
                 tmp['vlan_id'] = vif_c_id
 
                 vif_c_ifname = f'{vif_s_ifname}.{vif_c_id}'
                 c_vlan = VLANIf(vif_c_ifname, **tmp)
                 c_vlan.update(vif_c_config)
 
         # remove no longer required 802.1q VLAN interfaces
         for vif_id in config.get('vif_remove', {}):
             vif_ifname = f'{ifname}.{vif_id}'
             VLANIf(vif_ifname).remove()
 
         # create/update 802.1q VLAN interfaces
         for vif_id, vif_config in config.get('vif', {}).items():
             vif_ifname = f'{ifname}.{vif_id}'
             tmp = deepcopy(VLANIf.get_config())
             tmp['source_interface'] = ifname
             tmp['vlan_id'] = vif_id
 
             # We need to ensure that the string format is consistent, and we need to exclude redundant spaces.
             sep = ' '
             if 'egress_qos' in vif_config:
                 # Unwrap strings into arrays
                 egress_qos_array = vif_config['egress_qos'].split()
                 # The split array is spliced according to the fixed format
                 tmp['egress_qos'] = sep.join(egress_qos_array)
 
             if 'ingress_qos' in vif_config:
                 # Unwrap strings into arrays
                 ingress_qos_array = vif_config['ingress_qos'].split()
                 # The split array is spliced according to the fixed format
                 tmp['ingress_qos'] = sep.join(ingress_qos_array)
 
             # Since setting the QoS control parameters in the later stage will
             # not completely delete the old settings,
             # we still need to delete the VLAN encapsulation interface in order to
             # ensure that the changed settings are effective.
             cur_cfg = get_interface_config(vif_ifname)
             qos_str = ''
             tmp2 = dict_search('linkinfo.info_data.ingress_qos', cur_cfg)
             if 'ingress_qos' in tmp and tmp2:
                 for item in tmp2:
                     from_key = item['from']
                     to_key = item['to']
                     qos_str += f'{from_key}:{to_key} '
                 if qos_str != tmp['ingress_qos']:
                     if self.exists(vif_ifname):
                         VLANIf(vif_ifname).remove()
 
             qos_str = ''
             tmp2 = dict_search('linkinfo.info_data.egress_qos', cur_cfg)
             if 'egress_qos' in tmp and tmp2:
                 for item in tmp2:
                     from_key = item['from']
                     to_key = item['to']
                     qos_str += f'{from_key}:{to_key} '
                 if qos_str != tmp['egress_qos']:
                     if self.exists(vif_ifname):
                         VLANIf(vif_ifname).remove()
 
             vlan = VLANIf(vif_ifname, **tmp)
             vlan.update(vif_config)
 
 
 class VLANIf(Interface):
     """ Specific class which abstracts 802.1q and 802.1ad (Q-in-Q) VLAN interfaces """
     iftype = 'vlan'
 
     def _create(self):
         # bail out early if interface already exists
         if self.exists(f'{self.ifname}'):
             return
 
         # If source_interface or vlan_id was not explicitly defined (e.g. when
         # calling  VLANIf('eth0.1').remove() we can define source_interface and
         # vlan_id here, as it's quiet obvious that it would be eth0 in that case.
         if 'source_interface' not in self.config:
             self.config['source_interface'] = '.'.join(self.ifname.split('.')[:-1])
         if 'vlan_id' not in self.config:
             self.config['vlan_id'] = self.ifname.split('.')[-1]
 
         cmd = 'ip link add link {source_interface} name {ifname} type vlan id {vlan_id}'
         if 'protocol' in self.config:
             cmd += ' protocol {protocol}'
         if 'ingress_qos' in self.config:
             cmd += ' ingress-qos-map {ingress_qos}'
         if 'egress_qos' in self.config:
             cmd += ' egress-qos-map {egress_qos}'
 
         self._cmd(cmd.format(**self.config))
 
         # interface is always A/D down. It needs to be enabled explicitly
         self.set_admin_state('down')
 
     def set_admin_state(self, state):
         """
         Set interface administrative state to be 'up' or 'down'
 
         Example:
         >>> from vyos.ifconfig import Interface
         >>> Interface('eth0.10').set_admin_state('down')
         >>> Interface('eth0.10').get_admin_state()
         'down'
         """
         # A VLAN interface can only be placed in admin up state when
         # the lower interface is up, too
         lower_interface = glob(f'/sys/class/net/{self.ifname}/lower*/flags')[0]
         with open(lower_interface, 'r') as f:
             flags = f.read()
         # If parent is not up - bail out as we can not bring up the VLAN.
         # Flags are defined in kernel source include/uapi/linux/if.h
         if not int(flags, 16) & 1:
             return None
 
         return super().set_admin_state(state)
diff --git a/smoketest/scripts/cli/base_interfaces_test.py b/smoketest/scripts/cli/base_interfaces_test.py
index 366d71abd..a40b762a8 100644
--- a/smoketest/scripts/cli/base_interfaces_test.py
+++ b/smoketest/scripts/cli/base_interfaces_test.py
@@ -1,1075 +1,1079 @@
 # Copyright (C) 2019-2023 VyOS maintainers and contributors
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License version 2 or later as
 # published by the Free Software Foundation.
 #
 # This program is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 # GNU General Public License for more details.
 #
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 from binascii import hexlify
 
 from netifaces import AF_INET
 from netifaces import AF_INET6
 from netifaces import ifaddresses
 from netifaces import interfaces
 
 from base_vyostest_shim import VyOSUnitTestSHIM
 
 from vyos.configsession import ConfigSessionError
 from vyos.defaults import directories
 from vyos.ifconfig import Interface
 from vyos.ifconfig import Section
 from vyos.utils.file import read_file
 from vyos.utils.dict import dict_search
 from vyos.utils.process import process_named_running
 from vyos.utils.network import get_interface_config
 from vyos.utils.network import get_interface_vrf
 from vyos.utils.process import cmd
 from vyos.utils.network import is_intf_addr_assigned
 from vyos.utils.network import is_ipv6_link_local
 from vyos.xml_ref import cli_defined
 
 dhclient_base_dir = directories['isc_dhclient_dir']
 dhclient_process_name = 'dhclient'
 dhcp6c_base_dir = directories['dhcp6_client_dir']
 dhcp6c_process_name = 'dhcp6c'
 
 def is_mirrored_to(interface, mirror_if, qdisc):
     """
     Ask TC if we are mirroring traffic to a discrete interface.
 
     interface: source interface
     mirror_if: destination where we mirror our data to
     qdisc: must be ffff or 1 for ingress/egress
     """
     if qdisc not in ['ffff', '1']:
         raise ValueError()
 
     ret_val = False
     tmp = cmd(f'tc -s -p filter ls dev {interface} parent {qdisc}: | grep mirred')
     tmp = tmp.lower()
     if mirror_if in tmp:
         ret_val = True
     return ret_val
 
 class BasicInterfaceTest:
     class TestCase(VyOSUnitTestSHIM.TestCase):
         _test_dhcp = False
         _test_ip = False
         _test_mtu = False
         _test_vlan = False
         _test_qinq = False
         _test_ipv6 = False
         _test_ipv6_pd = False
         _test_ipv6_dhcpc6 = False
         _test_mirror = False
         _test_vrf = False
         _base_path = []
 
         _options = {}
         _interfaces = []
         _qinq_range = ['10', '20', '30']
         _vlan_range = ['100', '200', '300', '2000']
         _test_addr = ['192.0.2.1/26', '192.0.2.255/31', '192.0.2.64/32',
                       '2001:db8:1::ffff/64', '2001:db8:101::1/112']
 
         _mirror_interfaces = []
         # choose IPv6 minimum MTU value for tests - this must always work
         _mtu = '1280'
 
         @classmethod
         def setUpClass(cls):
             super(BasicInterfaceTest.TestCase, cls).setUpClass()
 
             # XXX the case of test_vif_8021q_mtu_limits, below, shows that
             # we should extend cli_defined to support more complex queries
             cls._test_vlan = cli_defined(cls._base_path, 'vif')
             cls._test_qinq = cli_defined(cls._base_path, 'vif-s')
             cls._test_dhcp = cli_defined(cls._base_path, 'dhcp-options')
             cls._test_ip = cli_defined(cls._base_path, 'ip')
             cls._test_ipv6 = cli_defined(cls._base_path, 'ipv6')
             cls._test_ipv6_dhcpc6 = cli_defined(cls._base_path, 'dhcpv6-options')
             cls._test_ipv6_pd = cli_defined(cls._base_path + ['dhcpv6-options'], 'pd')
             cls._test_mtu = cli_defined(cls._base_path, 'mtu')
             cls._test_vrf = cli_defined(cls._base_path, 'vrf')
 
             # Setup mirror interfaces for SPAN (Switch Port Analyzer)
             for span in cls._mirror_interfaces:
                 section = Section.section(span)
                 cls.cli_set(cls, ['interfaces', section, span])
 
         @classmethod
         def tearDownClass(cls):
             # Tear down mirror interfaces for SPAN (Switch Port Analyzer)
             for span in cls._mirror_interfaces:
                 section = Section.section(span)
                 cls.cli_delete(cls, ['interfaces', section, span])
 
             super(BasicInterfaceTest.TestCase, cls).tearDownClass()
 
         def tearDown(self):
             self.cli_delete(self._base_path)
             self.cli_commit()
 
             # Verify that no previously interface remained on the system
             for intf in self._interfaces:
                 self.assertNotIn(intf, interfaces())
 
             # No daemon started during tests should remain running
             for daemon in ['dhcp6c', 'dhclient']:
                 # if _interface list is populated do a more fine grained search
                 # by also checking the cmd arguments passed to the daemon
                 if self._interfaces:
                     for tmp in self._interfaces:
                         self.assertFalse(process_named_running(daemon, tmp))
                 else:
                     self.assertFalse(process_named_running(daemon))
 
         def test_dhcp_disable_interface(self):
             if not self._test_dhcp:
                 self.skipTest('not supported')
 
             # When interface is configured as admin down, it must be admin down
             # even when dhcpc starts on the given interface
             for interface in self._interfaces:
                 self.cli_set(self._base_path + [interface, 'disable'])
                 for option in self._options.get(interface, []):
                     self.cli_set(self._base_path + [interface] + option.split())
 
                 # Also enable DHCP (ISC DHCP always places interface in admin up
                 # state so we check that we do not start DHCP client.
                 # https://vyos.dev/T2767
                 self.cli_set(self._base_path + [interface, 'address', 'dhcp'])
 
             self.cli_commit()
 
             # Validate interface state
             for interface in self._interfaces:
                 flags = read_file(f'/sys/class/net/{interface}/flags')
                 self.assertEqual(int(flags, 16) & 1, 0)
 
         def test_dhcp_client_options(self):
             if not self._test_dhcp or not self._test_vrf:
                 self.skipTest('not supported')
 
             client_id = 'VyOS-router'
             distance = '100'
             hostname = 'vyos'
             vendor_class_id = 'vyos-vendor'
             user_class = 'vyos'
 
             for interface in self._interfaces:
                 for option in self._options.get(interface, []):
                     self.cli_set(self._base_path + [interface] + option.split())
 
                 self.cli_set(self._base_path + [interface, 'address', 'dhcp'])
                 self.cli_set(self._base_path + [interface, 'dhcp-options', 'client-id', client_id])
                 self.cli_set(self._base_path + [interface, 'dhcp-options', 'default-route-distance', distance])
                 self.cli_set(self._base_path + [interface, 'dhcp-options', 'host-name', hostname])
                 self.cli_set(self._base_path + [interface, 'dhcp-options', 'vendor-class-id', vendor_class_id])
                 self.cli_set(self._base_path + [interface, 'dhcp-options', 'user-class', user_class])
 
             self.cli_commit()
 
             for interface in self._interfaces:
                 # Check if dhclient process runs
                 dhclient_pid = process_named_running(dhclient_process_name, cmdline=interface, timeout=10)
                 self.assertTrue(dhclient_pid)
 
                 dhclient_config = read_file(f'{dhclient_base_dir}/dhclient_{interface}.conf')
                 self.assertIn(f'request subnet-mask, broadcast-address, routers, domain-name-servers', dhclient_config)
                 self.assertIn(f'require subnet-mask;', dhclient_config)
                 self.assertIn(f'send host-name "{hostname}";', dhclient_config)
                 self.assertIn(f'send dhcp-client-identifier "{client_id}";', dhclient_config)
                 self.assertIn(f'send vendor-class-identifier "{vendor_class_id}";', dhclient_config)
                 self.assertIn(f'send user-class "{user_class}";', dhclient_config)
 
                 # and the commandline has the appropriate options
                 cmdline = read_file(f'/proc/{dhclient_pid}/cmdline')
                 self.assertIn(f'-e\x00IF_METRIC={distance}', cmdline)
 
         def test_dhcp_vrf(self):
             if not self._test_dhcp or not self._test_vrf:
                 self.skipTest('not supported')
 
             vrf_name = 'purple4'
             self.cli_set(['vrf', 'name', vrf_name, 'table', '65000'])
 
             for interface in self._interfaces:
                 for option in self._options.get(interface, []):
                     self.cli_set(self._base_path + [interface] + option.split())
 
                 self.cli_set(self._base_path + [interface, 'address', 'dhcp'])
                 self.cli_set(self._base_path + [interface, 'vrf', vrf_name])
 
             self.cli_commit()
 
             # Validate interface state
             for interface in self._interfaces:
                 tmp = get_interface_vrf(interface)
                 self.assertEqual(tmp, vrf_name)
 
                 # Check if dhclient process runs
                 dhclient_pid = process_named_running(dhclient_process_name, cmdline=interface, timeout=10)
                 self.assertTrue(dhclient_pid)
                 # .. inside the appropriate VRF instance
                 vrf_pids = cmd(f'ip vrf pids {vrf_name}')
                 self.assertIn(str(dhclient_pid), vrf_pids)
                 # and the commandline has the appropriate options
                 cmdline = read_file(f'/proc/{dhclient_pid}/cmdline')
                 self.assertIn('-e\x00IF_METRIC=210', cmdline) # 210 is the default value
 
             self.cli_delete(['vrf', 'name', vrf_name])
 
         def test_dhcpv6_vrf(self):
             if not self._test_ipv6_dhcpc6 or not self._test_vrf:
                 self.skipTest('not supported')
 
             vrf_name = 'purple6'
             self.cli_set(['vrf', 'name', vrf_name, 'table', '65001'])
 
             # When interface is configured as admin down, it must be admin down
             # even when dhcpc starts on the given interface
             for interface in self._interfaces:
                 for option in self._options.get(interface, []):
                     self.cli_set(self._base_path + [interface] + option.split())
 
                 self.cli_set(self._base_path + [interface, 'address', 'dhcpv6'])
                 self.cli_set(self._base_path + [interface, 'vrf', vrf_name])
 
             self.cli_commit()
 
             # Validate interface state
             for interface in self._interfaces:
                 tmp = get_interface_vrf(interface)
                 self.assertEqual(tmp, vrf_name)
 
                 # Check if dhclient process runs
                 tmp = process_named_running(dhcp6c_process_name, cmdline=interface, timeout=10)
                 self.assertTrue(tmp)
                 # .. inside the appropriate VRF instance
                 vrf_pids = cmd(f'ip vrf pids {vrf_name}')
                 self.assertIn(str(tmp), vrf_pids)
 
             self.cli_delete(['vrf', 'name', vrf_name])
 
         def test_span_mirror(self):
             if not self._mirror_interfaces:
                 self.skipTest('not supported')
 
             # Check the two-way mirror rules of ingress and egress
             for mirror in self._mirror_interfaces:
                 for interface in self._interfaces:
                     self.cli_set(self._base_path + [interface, 'mirror', 'ingress', mirror])
                     self.cli_set(self._base_path + [interface, 'mirror', 'egress',  mirror])
 
             self.cli_commit()
 
             # Verify config
             for mirror in self._mirror_interfaces:
                 for interface in self._interfaces:
                     self.assertTrue(is_mirrored_to(interface, mirror, 'ffff'))
                     self.assertTrue(is_mirrored_to(interface, mirror, '1'))
 
         def test_interface_disable(self):
             # Check if description can be added to interface and
             # can be read back
             for intf in self._interfaces:
                 self.cli_set(self._base_path + [intf, 'disable'])
                 for option in self._options.get(intf, []):
                     self.cli_set(self._base_path + [intf] + option.split())
 
             self.cli_commit()
 
             # Validate interface description
             for intf in self._interfaces:
                 self.assertEqual(Interface(intf).get_admin_state(), 'down')
 
         def test_interface_description(self):
             # Check if description can be added to interface and
             # can be read back
             for intf in self._interfaces:
                 test_string=f'Description-Test-{intf}'
                 self.cli_set(self._base_path + [intf, 'description', test_string])
                 for option in self._options.get(intf, []):
                     self.cli_set(self._base_path + [intf] + option.split())
 
             self.cli_commit()
 
             # Validate interface description
             for intf in self._interfaces:
                 test_string=f'Description-Test-{intf}'
                 tmp = read_file(f'/sys/class/net/{intf}/ifalias')
                 self.assertEqual(tmp, test_string)
                 self.assertEqual(Interface(intf).get_alias(), test_string)
                 self.cli_delete(self._base_path + [intf, 'description'])
 
             self.cli_commit()
 
             # Validate remove interface description "empty"
             for intf in self._interfaces:
                 tmp = read_file(f'/sys/class/net/{intf}/ifalias')
                 self.assertEqual(tmp, str())
                 self.assertEqual(Interface(intf).get_alias(), str())
 
         def test_add_single_ip_address(self):
             addr = '192.0.2.0/31'
             for intf in self._interfaces:
                 self.cli_set(self._base_path + [intf, 'address', addr])
                 for option in self._options.get(intf, []):
                     self.cli_set(self._base_path + [intf] + option.split())
 
             self.cli_commit()
 
             for intf in self._interfaces:
                 self.assertTrue(is_intf_addr_assigned(intf, addr))
                 self.assertEqual(Interface(intf).get_admin_state(), 'up')
 
         def test_add_multiple_ip_addresses(self):
             # Add address
             for intf in self._interfaces:
                 for option in self._options.get(intf, []):
                     self.cli_set(self._base_path + [intf] + option.split())
                 for addr in self._test_addr:
                     self.cli_set(self._base_path + [intf, 'address', addr])
 
             self.cli_commit()
 
             # Validate address
             for intf in self._interfaces:
                 for af in AF_INET, AF_INET6:
                     for addr in ifaddresses(intf)[af]:
                         # checking link local addresses makes no sense
                         if is_ipv6_link_local(addr['addr']):
                             continue
 
                         self.assertTrue(is_intf_addr_assigned(intf, addr['addr']))
 
         def test_ipv6_link_local_address(self):
             # Common function for IPv6 link-local address assignemnts
             if not self._test_ipv6:
                 self.skipTest('not supported')
 
             for interface in self._interfaces:
                 base = self._base_path + [interface]
                 # just set the interface base without any option - some interfaces
                 # (VTI) do not require any option to be brought up
                 self.cli_set(base)
                 for option in self._options.get(interface, []):
                     self.cli_set(base + option.split())
 
             # after commit we must have an IPv6 link-local address
             self.cli_commit()
 
             for interface in self._interfaces:
                 self.assertIn(AF_INET6, ifaddresses(interface))
                 for addr in ifaddresses(interface)[AF_INET6]:
                     self.assertTrue(is_ipv6_link_local(addr['addr']))
 
             # disable IPv6 link-local address assignment
             for interface in self._interfaces:
                 base = self._base_path + [interface]
                 self.cli_set(base + ['ipv6', 'address', 'no-default-link-local'])
 
             # after commit we must have no IPv6 link-local address
             self.cli_commit()
 
             for interface in self._interfaces:
                 self.assertNotIn(AF_INET6, ifaddresses(interface))
 
         def test_interface_mtu(self):
             if not self._test_mtu:
                 self.skipTest('not supported')
 
             for intf in self._interfaces:
                 base = self._base_path + [intf]
                 self.cli_set(base + ['mtu', self._mtu])
                 for option in self._options.get(intf, []):
                     self.cli_set(base + option.split())
 
             # commit interface changes
             self.cli_commit()
 
             # verify changed MTU
             for intf in self._interfaces:
                 tmp = get_interface_config(intf)
                 self.assertEqual(tmp['mtu'], int(self._mtu))
 
         def test_mtu_1200_no_ipv6_interface(self):
             # Testcase if MTU can be changed to 1200 on non IPv6
             # enabled interfaces
             if not self._test_mtu:
                 self.skipTest('not supported')
 
             old_mtu = self._mtu
             self._mtu = '1200'
 
             for intf in self._interfaces:
                 base = self._base_path + [intf]
                 for option in self._options.get(intf, []):
                     self.cli_set(base + option.split())
                 self.cli_set(base + ['mtu', self._mtu])
 
             # check validate() - can not set low MTU if 'no-default-link-local'
             # is not set on CLI
             with self.assertRaises(ConfigSessionError):
                 self.cli_commit()
 
             for intf in self._interfaces:
                 base = self._base_path + [intf]
                 self.cli_set(base + ['ipv6', 'address', 'no-default-link-local'])
 
             # commit interface changes
             self.cli_commit()
 
             # verify changed MTU
             for intf in self._interfaces:
                 tmp = get_interface_config(intf)
                 self.assertEqual(tmp['mtu'], int(self._mtu))
 
             self._mtu = old_mtu
 
         def test_vif_8021q_interfaces(self):
             # XXX: This testcase is not allowed to run as first testcase, reason
             # is the Wireless test will first load the wifi kernel hwsim module
             # which creates a wlan0 and wlan1 interface which will fail the
             # tearDown() test in the end that no interface is allowed to survive!
             if not self._test_vlan:
                 self.skipTest('not supported')
 
             for interface in self._interfaces:
                 base = self._base_path + [interface]
                 for option in self._options.get(interface, []):
                     self.cli_set(base + option.split())
 
                 for vlan in self._vlan_range:
                     base = self._base_path + [interface, 'vif', vlan]
                     for address in self._test_addr:
                         self.cli_set(base + ['address', address])
 
             self.cli_commit()
 
             for intf in self._interfaces:
                 for vlan in self._vlan_range:
                     vif = f'{intf}.{vlan}'
                     for address in self._test_addr:
                         self.assertTrue(is_intf_addr_assigned(vif, address))
 
                     self.assertEqual(Interface(vif).get_admin_state(), 'up')
 
             # T4064: Delete interface addresses, keep VLAN interface
             for interface in self._interfaces:
                 base = self._base_path + [interface]
                 for vlan in self._vlan_range:
                     base = self._base_path + [interface, 'vif', vlan]
                     self.cli_delete(base + ['address'])
 
             self.cli_commit()
 
             # Verify no IP address is assigned
             for interface in self._interfaces:
                 for vlan in self._vlan_range:
                     vif = f'{intf}.{vlan}'
                     for address in self._test_addr:
                         self.assertFalse(is_intf_addr_assigned(vif, address))
 
 
         def test_vif_8021q_mtu_limits(self):
             # XXX: This testcase is not allowed to run as first testcase, reason
             # is the Wireless test will first load the wifi kernel hwsim module
             # which creates a wlan0 and wlan1 interface which will fail the
             # tearDown() test in the end that no interface is allowed to survive!
             if not self._test_vlan or not self._test_mtu:
                 self.skipTest('not supported')
 
             mtu_1500 = '1500'
             mtu_9000 = '9000'
 
             for interface in self._interfaces:
                 base = self._base_path + [interface]
                 self.cli_set(base + ['mtu', mtu_1500])
                 for option in self._options.get(interface, []):
                     self.cli_set(base + option.split())
                     if 'source-interface' in option:
                         iface = option.split()[-1]
                         iface_type = Section.section(iface)
                         self.cli_set(['interfaces', iface_type, iface, 'mtu', mtu_9000])
 
                 for vlan in self._vlan_range:
                     base = self._base_path + [interface, 'vif', vlan]
                     self.cli_set(base + ['mtu', mtu_9000])
 
             # check validate() - VIF MTU must not be larger the parent interface
             # MTU size.
             with self.assertRaises(ConfigSessionError):
                 self.cli_commit()
 
             # Change MTU on base interface to be the same as on the VIF interface
             for interface in self._interfaces:
                 base = self._base_path + [interface]
                 self.cli_set(base + ['mtu', mtu_9000])
 
             self.cli_commit()
 
             # Verify MTU on base and VIF interfaces
             for interface in self._interfaces:
                 tmp = get_interface_config(interface)
                 self.assertEqual(tmp['mtu'], int(mtu_9000))
 
                 for vlan in self._vlan_range:
                     tmp = get_interface_config(f'{interface}.{vlan}')
                     self.assertEqual(tmp['mtu'], int(mtu_9000))
 
 
         def test_vif_8021q_qos_change(self):
             # XXX: This testcase is not allowed to run as first testcase, reason
             # is the Wireless test will first load the wifi kernel hwsim module
             # which creates a wlan0 and wlan1 interface which will fail the
             # tearDown() test in the end that no interface is allowed to survive!
             if not self._test_vlan:
                 self.skipTest('not supported')
 
             for interface in self._interfaces:
                 base = self._base_path + [interface]
                 for option in self._options.get(interface, []):
                     self.cli_set(base + option.split())
 
                 for vlan in self._vlan_range:
                     base = self._base_path + [interface, 'vif', vlan]
                     self.cli_set(base + ['ingress-qos', '0:1'])
                     self.cli_set(base + ['egress-qos', '1:6'])
 
             self.cli_commit()
 
             for intf in self._interfaces:
                 for vlan in self._vlan_range:
                     vif = f'{intf}.{vlan}'
                     tmp = get_interface_config(f'{vif}')
 
                     tmp2 = dict_search('linkinfo.info_data.ingress_qos', tmp)
                     for item in tmp2 if tmp2 else []:
                         from_key = item['from']
                         to_key = item['to']
                         self.assertEqual(from_key, 0)
                         self.assertEqual(to_key, 1)
 
                     tmp2 = dict_search('linkinfo.info_data.egress_qos', tmp)
                     for item in tmp2 if tmp2 else []:
                         from_key = item['from']
                         to_key = item['to']
                         self.assertEqual(from_key, 1)
                         self.assertEqual(to_key, 6)
 
                     self.assertEqual(Interface(vif).get_admin_state(), 'up')
 
             new_ingress_qos_from = 1
             new_ingress_qos_to = 6
             new_egress_qos_from = 2
             new_egress_qos_to = 7
             for interface in self._interfaces:
                 base = self._base_path + [interface]
                 for vlan in self._vlan_range:
                     base = self._base_path + [interface, 'vif', vlan]
                     self.cli_set(base + ['ingress-qos', f'{new_ingress_qos_from}:{new_ingress_qos_to}'])
                     self.cli_set(base + ['egress-qos', f'{new_egress_qos_from}:{new_egress_qos_to}'])
 
             self.cli_commit()
 
             for intf in self._interfaces:
                 for vlan in self._vlan_range:
                     vif = f'{intf}.{vlan}'
                     tmp = get_interface_config(f'{vif}')
 
                     tmp2 = dict_search('linkinfo.info_data.ingress_qos', tmp)
                     if tmp2:
                         from_key = tmp2[0]['from']
                         to_key = tmp2[0]['to']
                         self.assertEqual(from_key, new_ingress_qos_from)
                         self.assertEqual(to_key, new_ingress_qos_to)
 
                     tmp2 = dict_search('linkinfo.info_data.egress_qos', tmp)
                     if tmp2:
                         from_key = tmp2[0]['from']
                         to_key = tmp2[0]['to']
                         self.assertEqual(from_key, new_egress_qos_from)
                         self.assertEqual(to_key, new_egress_qos_to)
 
         def test_vif_8021q_lower_up_down(self):
             # Testcase for https://vyos.dev/T3349
             if not self._test_vlan:
                 self.skipTest('not supported')
 
             for interface in self._interfaces:
                 base = self._base_path + [interface]
                 for option in self._options.get(interface, []):
                     self.cli_set(base + option.split())
 
                 # disable the lower interface
                 self.cli_set(base + ['disable'])
 
                 for vlan in self._vlan_range:
                     vlan_base = self._base_path + [interface, 'vif', vlan]
                     # disable the vlan interface
                     self.cli_set(vlan_base + ['disable'])
 
             self.cli_commit()
 
             # re-enable all lower interfaces
             for interface in self._interfaces:
                 base = self._base_path + [interface]
                 self.cli_delete(base + ['disable'])
 
             self.cli_commit()
 
             # verify that the lower interfaces are admin up and the vlan
             # interfaces are all admin down
             for interface in self._interfaces:
                 self.assertEqual(Interface(interface).get_admin_state(), 'up')
 
                 for vlan in self._vlan_range:
                     ifname = f'{interface}.{vlan}'
                     self.assertEqual(Interface(ifname).get_admin_state(), 'down')
 
 
         def test_vif_s_8021ad_vlan_interfaces(self):
             # XXX: This testcase is not allowed to run as first testcase, reason
             # is the Wireless test will first load the wifi kernel hwsim module
             # which creates a wlan0 and wlan1 interface which will fail the
             # tearDown() test in the end that no interface is allowed to survive!
             if not self._test_qinq:
                 self.skipTest('not supported')
 
             for interface in self._interfaces:
                 base = self._base_path + [interface]
                 for option in self._options.get(interface, []):
                     self.cli_set(base + option.split())
 
                 for vif_s in self._qinq_range:
                     for vif_c in self._vlan_range:
                         base = self._base_path + [interface, 'vif-s', vif_s, 'vif-c', vif_c]
                         self.cli_set(base + ['mtu', self._mtu])
                         for address in self._test_addr:
                             self.cli_set(base + ['address', address])
 
             self.cli_commit()
 
             for interface in self._interfaces:
                 for vif_s in self._qinq_range:
                     tmp = get_interface_config(f'{interface}.{vif_s}')
                     self.assertEqual(dict_search('linkinfo.info_data.protocol', tmp), '802.1ad')
 
                     for vif_c in self._vlan_range:
                         vif = f'{interface}.{vif_s}.{vif_c}'
                         # For an unknown reason this regularely fails on the QEMU builds,
                         # thus the test for reading back IP addresses is temporary
                         # disabled. There is no big deal here, as this uses the same
                         # methods on 802.1q and here it works and is verified.
 #                       for address in self._test_addr:
 #                           self.assertTrue(is_intf_addr_assigned(vif, address))
 
                         tmp = get_interface_config(vif)
                         self.assertEqual(tmp['mtu'], int(self._mtu))
 
 
             # T4064: Delete interface addresses, keep VLAN interface
             for interface in self._interfaces:
                 base = self._base_path + [interface]
                 for vif_s in self._qinq_range:
                     for vif_c in self._vlan_range:
                         self.cli_delete(self._base_path + [interface, 'vif-s', vif_s, 'vif-c', vif_c, 'address'])
 
             self.cli_commit()
             # Verify no IP address is assigned
             for interface in self._interfaces:
                 base = self._base_path + [interface]
                 for vif_s in self._qinq_range:
                     for vif_c in self._vlan_range:
                         vif = f'{interface}.{vif_s}.{vif_c}'
                         for address in self._test_addr:
                             self.assertFalse(is_intf_addr_assigned(vif, address))
 
             # T3972: remove vif-c interfaces from vif-s
             for interface in self._interfaces:
                 base = self._base_path + [interface]
                 for vif_s in self._qinq_range:
                     base = self._base_path + [interface, 'vif-s', vif_s, 'vif-c']
                     self.cli_delete(base)
 
             self.cli_commit()
 
 
         def test_vif_s_protocol_change(self):
             # XXX: This testcase is not allowed to run as first testcase, reason
             # is the Wireless test will first load the wifi kernel hwsim module
             # which creates a wlan0 and wlan1 interface which will fail the
             # tearDown() test in the end that no interface is allowed to survive!
             if not self._test_qinq:
                 self.skipTest('not supported')
 
             for interface in self._interfaces:
                 base = self._base_path + [interface]
                 for option in self._options.get(interface, []):
                     self.cli_set(base + option.split())
 
                 for vif_s in self._qinq_range:
                     for vif_c in self._vlan_range:
                         base = self._base_path + [interface, 'vif-s', vif_s, 'vif-c', vif_c]
                         for address in self._test_addr:
                             self.cli_set(base + ['address', address])
 
             self.cli_commit()
 
             for interface in self._interfaces:
                 for vif_s in self._qinq_range:
                     tmp = get_interface_config(f'{interface}.{vif_s}')
                     # check for the default value
                     self.assertEqual(tmp['linkinfo']['info_data']['protocol'], '802.1ad')
 
             # T3532: now change ethertype
             new_protocol = '802.1q'
             for interface in self._interfaces:
                 for vif_s in self._qinq_range:
                     base = self._base_path + [interface, 'vif-s', vif_s]
                     self.cli_set(base + ['protocol', new_protocol])
 
             self.cli_commit()
 
             # Verify new ethertype configuration
             for interface in self._interfaces:
                 for vif_s in self._qinq_range:
                     tmp = get_interface_config(f'{interface}.{vif_s}')
                     self.assertEqual(tmp['linkinfo']['info_data']['protocol'], new_protocol.upper())
 
         def test_interface_ip_options(self):
             if not self._test_ip:
                 self.skipTest('not supported')
 
             arp_tmo = '300'
             mss = '1420'
 
             for interface in self._interfaces:
                 path = self._base_path + [interface]
                 for option in self._options.get(interface, []):
                     self.cli_set(path + option.split())
 
                 # Options
                 if cli_defined(self._base_path + ['ip'], 'adjust-mss'):
                     self.cli_set(path + ['ip', 'adjust-mss', mss])
 
                 if cli_defined(self._base_path + ['ip'], 'arp-cache-timeout'):
                     self.cli_set(path + ['ip', 'arp-cache-timeout', arp_tmo])
 
                 if cli_defined(self._base_path + ['ip'], 'disable-arp-filter'):
                     self.cli_set(path + ['ip', 'disable-arp-filter'])
 
                 if cli_defined(self._base_path + ['ip'], 'disable-forwarding'):
                     self.cli_set(path + ['ip', 'disable-forwarding'])
 
                 if cli_defined(self._base_path + ['ip'], 'enable-directed-broadcast'):
                     self.cli_set(path + ['ip', 'enable-directed-broadcast'])
 
                 if cli_defined(self._base_path + ['ip'], 'enable-arp-accept'):
                     self.cli_set(path + ['ip', 'enable-arp-accept'])
 
                 if cli_defined(self._base_path + ['ip'], 'enable-arp-announce'):
                     self.cli_set(path + ['ip', 'enable-arp-announce'])
 
                 if cli_defined(self._base_path + ['ip'], 'enable-arp-ignore'):
                     self.cli_set(path + ['ip', 'enable-arp-ignore'])
 
                 if cli_defined(self._base_path + ['ip'], 'enable-proxy-arp'):
                     self.cli_set(path + ['ip', 'enable-proxy-arp'])
 
                 if cli_defined(self._base_path + ['ip'], 'proxy-arp-pvlan'):
                     self.cli_set(path + ['ip', 'proxy-arp-pvlan'])
 
                 if cli_defined(self._base_path + ['ip'], 'source-validation'):
                     self.cli_set(path + ['ip', 'source-validation', 'loose'])
 
             self.cli_commit()
 
             for interface in self._interfaces:
                 if cli_defined(self._base_path + ['ip'], 'adjust-mss'):
                     base_options = f'oifname "{interface}"'
                     out = cmd('sudo nft list chain raw VYOS_TCP_MSS')
                     for line in out.splitlines():
                         if line.startswith(base_options):
                             self.assertIn(f'tcp option maxseg size set {mss}', line)
 
                 if cli_defined(self._base_path + ['ip'], 'arp-cache-timeout'):
                     tmp = read_file(f'/proc/sys/net/ipv4/neigh/{interface}/base_reachable_time_ms')
                     self.assertEqual(tmp, str((int(arp_tmo) * 1000))) # tmo value is in milli seconds
 
                 proc_base = f'/proc/sys/net/ipv4/conf/{interface}'
 
                 if cli_defined(self._base_path + ['ip'], 'disable-arp-filter'):
                     tmp = read_file(f'{proc_base}/arp_filter')
                     self.assertEqual('0', tmp)
 
                 if cli_defined(self._base_path + ['ip'], 'enable-arp-accept'):
                     tmp = read_file(f'{proc_base}/arp_accept')
                     self.assertEqual('1', tmp)
 
                 if cli_defined(self._base_path + ['ip'], 'enable-arp-announce'):
                     tmp = read_file(f'{proc_base}/arp_announce')
                     self.assertEqual('1', tmp)
 
                 if cli_defined(self._base_path + ['ip'], 'enable-arp-ignore'):
                     tmp = read_file(f'{proc_base}/arp_ignore')
                     self.assertEqual('1', tmp)
 
                 if cli_defined(self._base_path + ['ip'], 'disable-forwarding'):
                     tmp = read_file(f'{proc_base}/forwarding')
                     self.assertEqual('0', tmp)
 
                 if cli_defined(self._base_path + ['ip'], 'enable-directed-broadcast'):
                     tmp = read_file(f'{proc_base}/bc_forwarding')
                     self.assertEqual('1', tmp)
 
                 if cli_defined(self._base_path + ['ip'], 'enable-proxy-arp'):
                     tmp = read_file(f'{proc_base}/proxy_arp')
                     self.assertEqual('1', tmp)
 
                 if cli_defined(self._base_path + ['ip'], 'proxy-arp-pvlan'):
                     tmp = read_file(f'{proc_base}/proxy_arp_pvlan')
                     self.assertEqual('1', tmp)
 
                 if cli_defined(self._base_path + ['ip'], 'source-validation'):
-                    tmp = read_file(f'{proc_base}/rp_filter')
-                    self.assertEqual('2', tmp)
+                    base_options = f'iifname "{interface}"'
+                    out = cmd('sudo nft list chain ip raw vyos_rpfilter')
+                    for line in out.splitlines():
+                        if line.startswith(base_options):
+                            self.assertIn('fib saddr oif 0', line)
+                            self.assertIn('drop', line)
 
         def test_interface_ipv6_options(self):
             if not self._test_ipv6:
                 self.skipTest('not supported')
 
             mss = '1400'
             dad_transmits = '10'
             accept_dad = '0'
             source_validation = 'strict'
 
             for interface in self._interfaces:
                 path = self._base_path + [interface]
                 for option in self._options.get(interface, []):
                     self.cli_set(path + option.split())
 
                 # Options
                 if cli_defined(self._base_path + ['ipv6'], 'adjust-mss'):
                     self.cli_set(path + ['ipv6', 'adjust-mss', mss])
 
                 if cli_defined(self._base_path + ['ipv6'], 'accept-dad'):
                     self.cli_set(path + ['ipv6', 'accept-dad', accept_dad])
 
                 if cli_defined(self._base_path + ['ipv6'], 'dup-addr-detect-transmits'):
                     self.cli_set(path + ['ipv6', 'dup-addr-detect-transmits', dad_transmits])
 
                 if cli_defined(self._base_path + ['ipv6'], 'disable-forwarding'):
                     self.cli_set(path + ['ipv6', 'disable-forwarding'])
 
                 if cli_defined(self._base_path + ['ipv6'], 'source-validation'):
                     self.cli_set(path + ['ipv6', 'source-validation', source_validation])
 
             self.cli_commit()
 
             for interface in self._interfaces:
                 proc_base = f'/proc/sys/net/ipv6/conf/{interface}'
                 if cli_defined(self._base_path + ['ipv6'], 'adjust-mss'):
                     base_options = f'oifname "{interface}"'
                     out = cmd('sudo nft list chain ip6 raw VYOS_TCP_MSS')
                     for line in out.splitlines():
                         if line.startswith(base_options):
                             self.assertIn(f'tcp option maxseg size set {mss}', line)
 
                 if cli_defined(self._base_path + ['ipv6'], 'accept-dad'):
                     tmp = read_file(f'{proc_base}/accept_dad')
                     self.assertEqual(accept_dad, tmp)
 
                 if cli_defined(self._base_path + ['ipv6'], 'dup-addr-detect-transmits'):
                     tmp = read_file(f'{proc_base}/dad_transmits')
                     self.assertEqual(dad_transmits, tmp)
 
                 if cli_defined(self._base_path + ['ipv6'], 'disable-forwarding'):
                     tmp = read_file(f'{proc_base}/forwarding')
                     self.assertEqual('0', tmp)
 
                 if cli_defined(self._base_path + ['ipv6'], 'source-validation'):
                     base_options = f'iifname "{interface}"'
                     out = cmd('sudo nft list chain ip6 raw vyos_rpfilter')
                     for line in out.splitlines():
                         if line.startswith(base_options):
                             self.assertIn('fib saddr . iif oif 0', line)
                             self.assertIn('drop', line)
 
         def test_dhcpv6_client_options(self):
             if not self._test_ipv6_dhcpc6:
                 self.skipTest('not supported')
 
             duid_base = 10
             for interface in self._interfaces:
                 duid = '00:01:00:01:27:71:db:f0:00:50:00:00:00:{}'.format(duid_base)
                 path = self._base_path + [interface]
                 for option in self._options.get(interface, []):
                     self.cli_set(path + option.split())
 
                 # Enable DHCPv6 client
                 self.cli_set(path + ['address', 'dhcpv6'])
                 self.cli_set(path + ['dhcpv6-options', 'no-release'])
                 self.cli_set(path + ['dhcpv6-options', 'rapid-commit'])
                 self.cli_set(path + ['dhcpv6-options', 'parameters-only'])
                 self.cli_set(path + ['dhcpv6-options', 'duid', duid])
                 duid_base += 1
 
             self.cli_commit()
 
             duid_base = 10
             for interface in self._interfaces:
                 duid = '00:01:00:01:27:71:db:f0:00:50:00:00:00:{}'.format(duid_base)
                 dhcpc6_config = read_file(f'{dhcp6c_base_dir}/dhcp6c.{interface}.conf')
                 self.assertIn(f'interface {interface} ' + '{', dhcpc6_config)
                 self.assertIn(f'  request domain-name-servers;', dhcpc6_config)
                 self.assertIn(f'  request domain-name;', dhcpc6_config)
                 self.assertIn(f'  information-only;', dhcpc6_config)
                 self.assertIn(f'  send ia-na 0;', dhcpc6_config)
                 self.assertIn(f'  send rapid-commit;', dhcpc6_config)
                 self.assertIn(f'  send client-id {duid};', dhcpc6_config)
                 self.assertIn('};', dhcpc6_config)
                 duid_base += 1
 
                 # Better ask the process about it's commandline in the future
                 pid = process_named_running(dhcp6c_process_name, cmdline=interface, timeout=10)
                 self.assertTrue(pid)
 
                 dhcp6c_options = read_file(f'/proc/{pid}/cmdline')
                 self.assertIn('-n', dhcp6c_options)
 
         def test_dhcpv6pd_auto_sla_id(self):
             if not self._test_ipv6_pd:
                 self.skipTest('not supported')
 
             prefix_len = '56'
             sla_len = str(64 - int(prefix_len))
 
             # Create delegatee interfaces first to avoid any confusion by dhcpc6
             # this is mainly an "issue" with virtual-ethernet interfaces
             delegatees = ['dum2340', 'dum2341', 'dum2342', 'dum2343', 'dum2344']
             for delegatee in delegatees:
                 section = Section.section(delegatee)
                 self.cli_set(['interfaces', section, delegatee])
 
             self.cli_commit()
 
             for interface in self._interfaces:
                 path = self._base_path + [interface]
                 for option in self._options.get(interface, []):
                     self.cli_set(path + option.split())
 
                 address = '1'
                 # prefix delegation stuff
                 pd_base = path + ['dhcpv6-options', 'pd', '0']
                 self.cli_set(pd_base + ['length', prefix_len])
 
                 for delegatee in delegatees:
                     self.cli_set(pd_base + ['interface', delegatee, 'address', address])
                     # increment interface address
                     address = str(int(address) + 1)
 
             self.cli_commit()
 
             for interface in self._interfaces:
                 dhcpc6_config = read_file(f'{dhcp6c_base_dir}/dhcp6c.{interface}.conf')
 
                 # verify DHCPv6 prefix delegation
                 self.assertIn(f'prefix ::/{prefix_len} infinity;', dhcpc6_config)
 
                 address = '1'
                 sla_id = '0'
                 for delegatee in delegatees:
                     self.assertIn(f'prefix-interface {delegatee}' + r' {', dhcpc6_config)
                     self.assertIn(f'ifid {address};', dhcpc6_config)
                     self.assertIn(f'sla-id {sla_id};', dhcpc6_config)
                     self.assertIn(f'sla-len {sla_len};', dhcpc6_config)
 
                     # increment sla-id
                     sla_id = str(int(sla_id) + 1)
                     # increment interface address
                     address = str(int(address) + 1)
 
                 # Check for running process
                 self.assertTrue(process_named_running(dhcp6c_process_name, cmdline=interface, timeout=10))
 
             for delegatee in delegatees:
                 # we can already cleanup the test delegatee interface here
                 # as until commit() is called, nothing happens
                 section = Section.section(delegatee)
                 self.cli_delete(['interfaces', section, delegatee])
 
         def test_dhcpv6pd_manual_sla_id(self):
             if not self._test_ipv6_pd:
                 self.skipTest('not supported')
 
             prefix_len = '56'
             sla_len = str(64 - int(prefix_len))
 
             # Create delegatee interfaces first to avoid any confusion by dhcpc6
             # this is mainly an "issue" with virtual-ethernet interfaces
             delegatees = ['dum3340', 'dum3341', 'dum3342', 'dum3343', 'dum3344']
             for delegatee in delegatees:
                 section = Section.section(delegatee)
                 self.cli_set(['interfaces', section, delegatee])
 
             self.cli_commit()
 
             for interface in self._interfaces:
                 path = self._base_path + [interface]
                 for option in self._options.get(interface, []):
                     self.cli_set(path + option.split())
 
                 # prefix delegation stuff
                 address = '1'
                 sla_id = '1'
                 pd_base = path + ['dhcpv6-options', 'pd', '0']
                 self.cli_set(pd_base + ['length', prefix_len])
 
                 for delegatee in delegatees:
                     self.cli_set(pd_base + ['interface', delegatee, 'address', address])
                     self.cli_set(pd_base + ['interface', delegatee, 'sla-id', sla_id])
 
                     # increment interface address
                     address = str(int(address) + 1)
                     sla_id = str(int(sla_id) + 1)
 
             self.cli_commit()
 
             # Verify dhcpc6 client configuration
             for interface in self._interfaces:
                 address = '1'
                 sla_id = '1'
                 dhcpc6_config = read_file(f'{dhcp6c_base_dir}/dhcp6c.{interface}.conf')
 
                 # verify DHCPv6 prefix delegation
                 self.assertIn(f'prefix ::/{prefix_len} infinity;', dhcpc6_config)
 
                 for delegatee in delegatees:
                     self.assertIn(f'prefix-interface {delegatee}' + r' {', dhcpc6_config)
                     self.assertIn(f'ifid {address};', dhcpc6_config)
                     self.assertIn(f'sla-id {sla_id};', dhcpc6_config)
                     self.assertIn(f'sla-len {sla_len};', dhcpc6_config)
 
                     # increment sla-id
                     sla_id = str(int(sla_id) + 1)
                     # increment interface address
                     address = str(int(address) + 1)
 
                 # Check for running process
                 self.assertTrue(process_named_running(dhcp6c_process_name, cmdline=interface, timeout=10))
 
             for delegatee in delegatees:
                 # we can already cleanup the test delegatee interface here
                 # as until commit() is called, nothing happens
                 section = Section.section(delegatee)
                 self.cli_delete(['interfaces', section, delegatee])
diff --git a/smoketest/scripts/cli/test_firewall.py b/smoketest/scripts/cli/test_firewall.py
index a3885158b..f74a33566 100755
--- a/smoketest/scripts/cli/test_firewall.py
+++ b/smoketest/scripts/cli/test_firewall.py
@@ -1,759 +1,763 @@
 #!/usr/bin/env python3
 #
 # Copyright (C) 2021-2022 VyOS maintainers and contributors
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License version 2 or later as
 # published by the Free Software Foundation.
 #
 # This program is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 # GNU General Public License for more details.
 #
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 import unittest
 
 from glob import glob
 from time import sleep
 
 from base_vyostest_shim import VyOSUnitTestSHIM
 
 from vyos.configsession import ConfigSessionError
 from vyos.utils.process import cmd
 from vyos.utils.process import run
 
 sysfs_config = {
     'all_ping': {'sysfs': '/proc/sys/net/ipv4/icmp_echo_ignore_all', 'default': '0', 'test_value': 'disable'},
     'broadcast_ping': {'sysfs': '/proc/sys/net/ipv4/icmp_echo_ignore_broadcasts', 'default': '1', 'test_value': 'enable'},
     'ip_src_route': {'sysfs': '/proc/sys/net/ipv4/conf/*/accept_source_route', 'default': '0', 'test_value': 'enable'},
     'ipv6_receive_redirects': {'sysfs': '/proc/sys/net/ipv6/conf/*/accept_redirects', 'default': '0', 'test_value': 'enable'},
     'ipv6_src_route': {'sysfs': '/proc/sys/net/ipv6/conf/*/accept_source_route', 'default': '-1', 'test_value': 'enable'},
     'log_martians': {'sysfs': '/proc/sys/net/ipv4/conf/all/log_martians', 'default': '1', 'test_value': 'disable'},
     'receive_redirects': {'sysfs': '/proc/sys/net/ipv4/conf/*/accept_redirects', 'default': '0', 'test_value': 'enable'},
     'send_redirects': {'sysfs': '/proc/sys/net/ipv4/conf/*/send_redirects', 'default': '1', 'test_value': 'disable'},
     'syn_cookies': {'sysfs': '/proc/sys/net/ipv4/tcp_syncookies', 'default': '1', 'test_value': 'disable'},
     'twa_hazards_protection': {'sysfs': '/proc/sys/net/ipv4/tcp_rfc1337', 'default': '0', 'test_value': 'enable'}
 }
 
 class TestFirewall(VyOSUnitTestSHIM.TestCase):
     @classmethod
     def setUpClass(cls):
         super(TestFirewall, cls).setUpClass()
 
         # ensure we can also run this test on a live system - so lets clean
         # out the current configuration :)
         cls.cli_delete(cls, ['firewall'])
 
     @classmethod
     def tearDownClass(cls):
         super(TestFirewall, cls).tearDownClass()
 
     def tearDown(self):
         self.cli_delete(['firewall'])
         self.cli_commit()
 
         # Verify chains/sets are cleaned up from nftables
         nftables_search = [
             ['set M_smoketest_mac'],
             ['set N_smoketest_network'],
             ['set P_smoketest_port'],
             ['set D_smoketest_domain'],
             ['set RECENT_smoketest_4'],
             ['chain NAME_smoketest']
         ]
 
         self.verify_nftables(nftables_search, 'ip vyos_filter', inverse=True)
 
     def verify_nftables(self, nftables_search, table, inverse=False, args=''):
         nftables_output = cmd(f'sudo nft {args} list table {table}')
 
         for search in nftables_search:
             matched = False
             for line in nftables_output.split("\n"):
                 if all(item in line for item in search):
                     matched = True
                     break
             self.assertTrue(not matched if inverse else matched, msg=search)
 
     def verify_nftables_chain(self, nftables_search, table, chain, inverse=False, args=''):
         nftables_output = cmd(f'sudo nft {args} list chain {table} {chain}')
 
         for search in nftables_search:
             matched = False
             for line in nftables_output.split("\n"):
                 if all(item in line for item in search):
                     matched = True
                     break
             self.assertTrue(not matched if inverse else matched, msg=search)
 
     def wait_for_domain_resolver(self, table, set_name, element, max_wait=10):
         # Resolver no longer blocks commit, need to wait for daemon to populate set
         count = 0
         while count < max_wait:
             code = run(f'sudo nft get element {table} {set_name} {{ {element} }}')
             if code == 0:
                 return True
             count += 1
             sleep(1)
         return False
 
     def test_geoip(self):
         self.cli_set(['firewall', 'ipv4', 'name', 'smoketest', 'rule', '1', 'action', 'drop'])
         self.cli_set(['firewall', 'ipv4', 'name', 'smoketest', 'rule', '1', 'source', 'geoip', 'country-code', 'se'])
         self.cli_set(['firewall', 'ipv4', 'name', 'smoketest', 'rule', '1', 'source', 'geoip', 'country-code', 'gb'])
         self.cli_set(['firewall', 'ipv4', 'name', 'smoketest', 'rule', '2', 'action', 'accept'])
         self.cli_set(['firewall', 'ipv4', 'name', 'smoketest', 'rule', '2', 'source', 'geoip', 'country-code', 'de'])
         self.cli_set(['firewall', 'ipv4', 'name', 'smoketest', 'rule', '2', 'source', 'geoip', 'country-code', 'fr'])
         self.cli_set(['firewall', 'ipv4', 'name', 'smoketest', 'rule', '2', 'source', 'geoip', 'inverse-match'])
 
         self.cli_commit()
 
         nftables_search = [
             ['ip saddr @GEOIP_CC_name_smoketest_1', 'drop'],
             ['ip saddr != @GEOIP_CC_name_smoketest_2', 'accept']
         ]
 
         # -t prevents 1000+ GeoIP elements being returned
         self.verify_nftables(nftables_search, 'ip vyos_filter', args='-t')
 
     def test_groups(self):
         hostmap_path = ['system', 'static-host-mapping', 'host-name']
         example_org = ['192.0.2.8', '192.0.2.10', '192.0.2.11']
 
         self.cli_set(hostmap_path + ['example.com', 'inet', '192.0.2.5'])
         for ips in example_org:
             self.cli_set(hostmap_path + ['example.org', 'inet', ips])
 
         self.cli_commit()
 
         self.cli_set(['firewall', 'group', 'mac-group', 'smoketest_mac', 'mac-address', '00:01:02:03:04:05'])
         self.cli_set(['firewall', 'group', 'network-group', 'smoketest_network', 'network', '172.16.99.0/24'])
         self.cli_set(['firewall', 'group', 'port-group', 'smoketest_port', 'port', '53'])
         self.cli_set(['firewall', 'group', 'port-group', 'smoketest_port', 'port', '123'])
         self.cli_set(['firewall', 'group', 'domain-group', 'smoketest_domain', 'address', 'example.com'])
         self.cli_set(['firewall', 'group', 'domain-group', 'smoketest_domain', 'address', 'example.org'])
         self.cli_set(['firewall', 'group', 'interface-group', 'smoketest_interface', 'interface', 'eth0'])
         self.cli_set(['firewall', 'group', 'interface-group', 'smoketest_interface', 'interface', 'vtun0'])
 
         self.cli_set(['firewall', 'ipv4', 'forward', 'filter', 'rule', '1', 'action', 'accept'])
         self.cli_set(['firewall', 'ipv4', 'forward', 'filter', 'rule', '1', 'source', 'group', 'network-group', 'smoketest_network'])
         self.cli_set(['firewall', 'ipv4', 'forward', 'filter', 'rule', '1', 'destination', 'address', '172.16.10.10'])
         self.cli_set(['firewall', 'ipv4', 'forward', 'filter', 'rule', '1', 'destination', 'group', 'port-group', 'smoketest_port'])
         self.cli_set(['firewall', 'ipv4', 'forward', 'filter', 'rule', '1', 'protocol', 'tcp_udp'])
         self.cli_set(['firewall', 'ipv4', 'forward', 'filter', 'rule', '2', 'action', 'accept'])
         self.cli_set(['firewall', 'ipv4', 'forward', 'filter', 'rule', '2', 'source', 'group', 'mac-group', 'smoketest_mac'])
         self.cli_set(['firewall', 'ipv4', 'forward', 'filter', 'rule', '3', 'action', 'accept'])
         self.cli_set(['firewall', 'ipv4', 'forward', 'filter', 'rule', '3', 'source', 'group', 'domain-group', 'smoketest_domain'])
         self.cli_set(['firewall', 'ipv4', 'forward', 'filter', 'rule', '4', 'action', 'accept'])
         self.cli_set(['firewall', 'ipv4', 'forward', 'filter', 'rule', '4', 'outbound-interface', 'group', '!smoketest_interface'])
 
         self.cli_commit()
 
         self.wait_for_domain_resolver('ip vyos_filter', 'D_smoketest_domain', '192.0.2.5')
 
         nftables_search = [
             ['ip saddr @N_smoketest_network', 'ip daddr 172.16.10.10', 'th dport @P_smoketest_port', 'accept'],
             ['elements = { 172.16.99.0/24 }'],
             ['elements = { 53, 123 }'],
             ['ether saddr @M_smoketest_mac', 'accept'],
             ['elements = { 00:01:02:03:04:05 }'],
             ['set D_smoketest_domain'],
             ['elements = { 192.0.2.5, 192.0.2.8,'],
             ['192.0.2.10, 192.0.2.11 }'],
             ['ip saddr @D_smoketest_domain', 'accept'],
             ['oifname != @I_smoketest_interface', 'accept']
         ]
         self.verify_nftables(nftables_search, 'ip vyos_filter')
 
         self.cli_delete(['system', 'static-host-mapping'])
         self.cli_commit()
 
     def test_nested_groups(self):
         self.cli_set(['firewall', 'group', 'network-group', 'smoketest_network', 'network', '172.16.99.0/24'])
         self.cli_set(['firewall', 'group', 'network-group', 'smoketest_network1', 'network', '172.16.101.0/24'])
         self.cli_set(['firewall', 'group', 'network-group', 'smoketest_network1', 'include', 'smoketest_network'])
         self.cli_set(['firewall', 'group', 'port-group', 'smoketest_port', 'port', '53'])
         self.cli_set(['firewall', 'group', 'port-group', 'smoketest_port1', 'port', '123'])
         self.cli_set(['firewall', 'group', 'port-group', 'smoketest_port1', 'include', 'smoketest_port'])
         self.cli_set(['firewall', 'ipv4', 'name', 'smoketest', 'rule', '1', 'action', 'accept'])
         self.cli_set(['firewall', 'ipv4', 'name', 'smoketest', 'rule', '1', 'source', 'group', 'network-group', 'smoketest_network1'])
         self.cli_set(['firewall', 'ipv4', 'name', 'smoketest', 'rule', '1', 'destination', 'group', 'port-group', 'smoketest_port1'])
         self.cli_set(['firewall', 'ipv4', 'name', 'smoketest', 'rule', '1', 'protocol', 'tcp_udp'])
 
         self.cli_commit()
 
         # Test circular includes
         self.cli_set(['firewall', 'group', 'network-group', 'smoketest_network', 'include', 'smoketest_network1'])
         with self.assertRaises(ConfigSessionError):
             self.cli_commit()
 
         self.cli_delete(['firewall', 'group', 'network-group', 'smoketest_network', 'include', 'smoketest_network1'])
 
         nftables_search = [
             ['ip saddr @N_smoketest_network1', 'th dport @P_smoketest_port1', 'accept'],
             ['elements = { 172.16.99.0/24, 172.16.101.0/24 }'],
             ['elements = { 53, 123 }']
         ]
 
         self.verify_nftables(nftables_search, 'ip vyos_filter')
 
     def test_ipv4_basic_rules(self):
         name = 'smoketest'
         interface = 'eth0'
         interface_inv = '!eth0'
         interface_wc = 'l2tp*'
         mss_range = '501-1460'
         conn_mark = '555'
 
         self.cli_set(['firewall', 'ipv4', 'name', name, 'default-action', 'drop'])
         self.cli_set(['firewall', 'ipv4', 'name', name, 'default-log'])
         self.cli_set(['firewall', 'ipv4', 'name', name, 'rule', '1', 'action', 'accept'])
         self.cli_set(['firewall', 'ipv4', 'name', name, 'rule', '1', 'source', 'address', '172.16.20.10'])
         self.cli_set(['firewall', 'ipv4', 'name', name, 'rule', '1', 'destination', 'address', '172.16.10.10'])
         self.cli_set(['firewall', 'ipv4', 'name', name, 'rule', '1', 'log'])
         self.cli_set(['firewall', 'ipv4', 'name', name, 'rule', '1', 'log-options', 'level', 'debug'])
         self.cli_set(['firewall', 'ipv4', 'name', name, 'rule', '1', 'ttl', 'eq', '15'])
         self.cli_set(['firewall', 'ipv4', 'name', name, 'rule', '2', 'action', 'reject'])
         self.cli_set(['firewall', 'ipv4', 'name', name, 'rule', '2', 'protocol', 'tcp'])
         self.cli_set(['firewall', 'ipv4', 'name', name, 'rule', '2', 'destination', 'port', '8888'])
         self.cli_set(['firewall', 'ipv4', 'name', name, 'rule', '2', 'log'])
         self.cli_set(['firewall', 'ipv4', 'name', name, 'rule', '2', 'log-options', 'level', 'err'])
         self.cli_set(['firewall', 'ipv4', 'name', name, 'rule', '2', 'tcp', 'flags', 'syn'])
         self.cli_set(['firewall', 'ipv4', 'name', name, 'rule', '2', 'tcp', 'flags', 'not', 'ack'])
         self.cli_set(['firewall', 'ipv4', 'name', name, 'rule', '2', 'ttl', 'gt', '102'])
 
         self.cli_set(['firewall', 'ipv4', 'forward', 'filter', 'default-action', 'drop'])
         self.cli_set(['firewall', 'ipv4', 'forward', 'filter', 'default-log'])
         self.cli_set(['firewall', 'ipv4', 'forward', 'filter', 'rule', '3', 'action', 'accept'])
         self.cli_set(['firewall', 'ipv4', 'forward', 'filter', 'rule', '3', 'protocol', 'tcp'])
         self.cli_set(['firewall', 'ipv4', 'forward', 'filter', 'rule', '3', 'destination', 'port', '22'])
         self.cli_set(['firewall', 'ipv4', 'forward', 'filter', 'rule', '3', 'limit', 'rate', '5/minute'])
         self.cli_set(['firewall', 'ipv4', 'forward', 'filter', 'rule', '3', 'log'])
         self.cli_set(['firewall', 'ipv4', 'forward', 'filter', 'rule', '4', 'action', 'drop'])
         self.cli_set(['firewall', 'ipv4', 'forward', 'filter', 'rule', '4', 'protocol', 'tcp'])
         self.cli_set(['firewall', 'ipv4', 'forward', 'filter', 'rule', '4', 'destination', 'port', '22'])
         self.cli_set(['firewall', 'ipv4', 'forward', 'filter', 'rule', '4', 'recent', 'count', '10'])
         self.cli_set(['firewall', 'ipv4', 'forward', 'filter', 'rule', '4', 'recent', 'time', 'minute'])
         self.cli_set(['firewall', 'ipv4', 'forward', 'filter', 'rule', '4', 'packet-type', 'host'])
 
         self.cli_set(['firewall', 'ipv4', 'input', 'filter', 'rule', '5', 'action', 'accept'])
         self.cli_set(['firewall', 'ipv4', 'input', 'filter', 'rule', '5', 'protocol', 'tcp'])
         self.cli_set(['firewall', 'ipv4', 'input', 'filter', 'rule', '5', 'tcp', 'flags', 'syn'])
         self.cli_set(['firewall', 'ipv4', 'input', 'filter', 'rule', '5', 'tcp', 'mss', mss_range])
         self.cli_set(['firewall', 'ipv4', 'input', 'filter', 'rule', '5', 'packet-type', 'broadcast'])
         self.cli_set(['firewall', 'ipv4', 'input', 'filter', 'rule', '5', 'inbound-interface', 'name', interface_wc])
         self.cli_set(['firewall', 'ipv4', 'input', 'filter', 'rule', '6', 'action', 'return'])
         self.cli_set(['firewall', 'ipv4', 'input', 'filter', 'rule', '6', 'protocol', 'gre'])
         self.cli_set(['firewall', 'ipv4', 'input', 'filter', 'rule', '6', 'connection-mark', conn_mark])
 
         self.cli_set(['firewall', 'ipv4', 'output', 'filter', 'default-action', 'drop'])
         self.cli_set(['firewall', 'ipv4', 'output', 'filter', 'default-log'])
         self.cli_set(['firewall', 'ipv4', 'output', 'filter', 'rule', '5', 'action', 'drop'])
         self.cli_set(['firewall', 'ipv4', 'output', 'filter', 'rule', '5', 'protocol', 'gre'])
         self.cli_set(['firewall', 'ipv4', 'output', 'filter', 'rule', '5', 'outbound-interface', 'name', interface_inv])
         self.cli_set(['firewall', 'ipv4', 'output', 'filter', 'rule', '6', 'action', 'return'])
         self.cli_set(['firewall', 'ipv4', 'output', 'filter', 'rule', '6', 'protocol', 'icmp'])
         self.cli_set(['firewall', 'ipv4', 'output', 'filter', 'rule', '6', 'connection-mark', conn_mark])
 
         self.cli_commit()
 
         mark_hex = "{0:#010x}".format(int(conn_mark))
 
         nftables_search = [
             ['chain VYOS_FORWARD_filter'],
             ['type filter hook forward priority filter; policy accept;'],
             ['tcp dport 22', 'limit rate 5/minute', 'accept'],
             ['tcp dport 22', 'add @RECENT_FWD_filter_4 { ip saddr limit rate over 10/minute burst 10 packets }', 'meta pkttype host', 'drop'],
             ['log prefix "[ipv4-FWD-filter-default-D]"','FWD-filter default-action drop', 'drop'],
             ['chain VYOS_INPUT_filter'],
             ['type filter hook input priority filter; policy accept;'],
             ['tcp flags & syn == syn', f'tcp option maxseg size {mss_range}', f'iifname "{interface_wc}"', 'meta pkttype broadcast', 'accept'],
             ['meta l4proto gre', f'ct mark {mark_hex}', 'return'],
             ['INP-filter default-action accept', 'accept'],
             ['chain VYOS_OUTPUT_filter'],
             ['type filter hook output priority filter; policy accept;'],
             ['meta l4proto gre', f'oifname != "{interface}"', 'drop'],
             ['meta l4proto icmp', f'ct mark {mark_hex}', 'return'],
             ['chain NAME_smoketest'],
             ['saddr 172.16.20.10', 'daddr 172.16.10.10', 'log prefix "[ipv4-NAM-smoketest-1-A]" log level debug', 'ip ttl 15', 'accept'],
             ['tcp flags syn / syn,ack', 'tcp dport 8888', 'log prefix "[ipv4-NAM-smoketest-2-R]" log level err', 'ip ttl > 102', 'reject'],
             ['log prefix "[ipv4-smoketest-default-D]"','smoketest default-action', 'drop']
         ]
 
         self.verify_nftables(nftables_search, 'ip vyos_filter')
 
     def test_ipv4_advanced(self):
         name = 'smoketest-adv'
         name2 = 'smoketest-adv2'
         interface = 'eth0'
 
         self.cli_set(['firewall', 'ipv4', 'name', name, 'default-action', 'drop'])
         self.cli_set(['firewall', 'ipv4', 'name', name, 'default-log'])
 
         self.cli_set(['firewall', 'ipv4', 'name', name, 'rule', '6', 'action', 'accept'])
         self.cli_set(['firewall', 'ipv4', 'name', name, 'rule', '6', 'packet-length', '64'])
         self.cli_set(['firewall', 'ipv4', 'name', name, 'rule', '6', 'packet-length', '512'])
         self.cli_set(['firewall', 'ipv4', 'name', name, 'rule', '6', 'packet-length', '1024'])
         self.cli_set(['firewall', 'ipv4', 'name', name, 'rule', '6', 'dscp', '17'])
         self.cli_set(['firewall', 'ipv4', 'name', name, 'rule', '6', 'dscp', '52'])
         self.cli_set(['firewall', 'ipv4', 'name', name, 'rule', '6', 'log'])
         self.cli_set(['firewall', 'ipv4', 'name', name, 'rule', '6', 'log-options', 'group', '66'])
         self.cli_set(['firewall', 'ipv4', 'name', name, 'rule', '6', 'log-options', 'snapshot-length', '6666'])
         self.cli_set(['firewall', 'ipv4', 'name', name, 'rule', '6', 'log-options', 'queue-threshold','32000'])
 
         self.cli_set(['firewall', 'ipv4', 'name', name, 'rule', '7', 'action', 'accept'])
         self.cli_set(['firewall', 'ipv4', 'name', name, 'rule', '7', 'packet-length', '1-30000'])
         self.cli_set(['firewall', 'ipv4', 'name', name, 'rule', '7', 'packet-length-exclude', '60000-65535'])
         self.cli_set(['firewall', 'ipv4', 'name', name, 'rule', '7', 'dscp', '3-11'])
         self.cli_set(['firewall', 'ipv4', 'name', name, 'rule', '7', 'dscp-exclude', '21-25'])
 
         self.cli_set(['firewall', 'ipv4', 'forward', 'filter', 'default-action', 'drop'])
         self.cli_set(['firewall', 'ipv4', 'forward', 'filter', 'rule', '1', 'source', 'address', '198.51.100.1'])
         self.cli_set(['firewall', 'ipv4', 'forward', 'filter', 'rule', '1', 'mark', '1010'])
         self.cli_set(['firewall', 'ipv4', 'forward', 'filter', 'rule', '1', 'action', 'jump'])
         self.cli_set(['firewall', 'ipv4', 'forward', 'filter', 'rule', '1', 'jump-target', name])
 
         self.cli_set(['firewall', 'ipv4', 'input', 'filter', 'rule', '2', 'protocol', 'tcp'])
         self.cli_set(['firewall', 'ipv4', 'input', 'filter', 'rule', '2', 'mark', '!98765'])
         self.cli_set(['firewall', 'ipv4', 'input', 'filter', 'rule', '2', 'action', 'queue'])
         self.cli_set(['firewall', 'ipv4', 'input', 'filter', 'rule', '2', 'queue', '3'])
         self.cli_set(['firewall', 'ipv4', 'input', 'filter', 'rule', '3', 'protocol', 'udp'])
         self.cli_set(['firewall', 'ipv4', 'input', 'filter', 'rule', '3', 'action', 'queue'])
         self.cli_set(['firewall', 'ipv4', 'input', 'filter', 'rule', '3', 'queue-options', 'fanout'])
         self.cli_set(['firewall', 'ipv4', 'input', 'filter', 'rule', '3', 'queue-options', 'bypass'])
         self.cli_set(['firewall', 'ipv4', 'input', 'filter', 'rule', '3', 'queue', '0-15'])
 
         self.cli_commit()
 
         nftables_search = [
             ['chain VYOS_FORWARD_filter'],
             ['type filter hook forward priority filter; policy accept;'],
             ['ip saddr 198.51.100.1', 'meta mark 0x000003f2', f'jump NAME_{name}'],
             ['FWD-filter default-action drop', 'drop'],
             ['chain VYOS_INPUT_filter'],
             ['type filter hook input priority filter; policy accept;'],
             ['meta mark != 0x000181cd', 'meta l4proto tcp','queue to 3'],
             ['meta l4proto udp','queue flags bypass,fanout to 0-15'],
             ['INP-filter default-action accept', 'accept'],
             [f'chain NAME_{name}'],
             ['ip length { 64, 512, 1024 }', 'ip dscp { 0x11, 0x34 }', f'log prefix "[ipv4-NAM-{name}-6-A]" log group 66 snaplen 6666 queue-threshold 32000', 'accept'],
             ['ip length 1-30000', 'ip length != 60000-65535', 'ip dscp 0x03-0x0b', 'ip dscp != 0x15-0x19', 'accept'],
             [f'log prefix "[ipv4-{name}-default-D]"', 'drop']
         ]
 
         self.verify_nftables(nftables_search, 'ip vyos_filter')
 
     def test_ipv4_mask(self):
         name = 'smoketest-mask'
         interface = 'eth0'
 
         self.cli_set(['firewall', 'group', 'address-group', 'mask_group', 'address', '1.1.1.1'])
 
         self.cli_set(['firewall', 'ipv4', 'name', name, 'default-action', 'drop'])
         self.cli_set(['firewall', 'ipv4', 'name', name, 'default-log'])
 
         self.cli_set(['firewall', 'ipv4', 'name', name, 'rule', '1', 'action', 'drop'])
         self.cli_set(['firewall', 'ipv4', 'name', name, 'rule', '1', 'destination', 'address', '0.0.1.2'])
         self.cli_set(['firewall', 'ipv4', 'name', name, 'rule', '1', 'destination', 'address-mask', '0.0.255.255'])
 
         self.cli_set(['firewall', 'ipv4', 'name', name, 'rule', '2', 'action', 'accept'])
         self.cli_set(['firewall', 'ipv4', 'name', name, 'rule', '2', 'source', 'address', '!0.0.3.4'])
         self.cli_set(['firewall', 'ipv4', 'name', name, 'rule', '2', 'source', 'address-mask', '0.0.255.255'])
 
         self.cli_set(['firewall', 'ipv4', 'name', name, 'rule', '3', 'action', 'drop'])
         self.cli_set(['firewall', 'ipv4', 'name', name, 'rule', '3', 'source', 'group', 'address-group', 'mask_group'])
         self.cli_set(['firewall', 'ipv4', 'name', name, 'rule', '3', 'source', 'address-mask', '0.0.255.255'])
 
         self.cli_commit()
 
         nftables_search = [
             [f'daddr & 0.0.255.255 == 0.0.1.2'],
             [f'saddr & 0.0.255.255 != 0.0.3.4'],
             [f'saddr & 0.0.255.255 == @A_mask_group']
         ]
 
         self.verify_nftables(nftables_search, 'ip vyos_filter')
 
 
     def test_ipv6_basic_rules(self):
         name = 'v6-smoketest'
         interface = 'eth0'
 
         self.cli_set(['firewall', 'global-options', 'state-policy', 'established', 'action', 'accept'])
         self.cli_set(['firewall', 'global-options', 'state-policy', 'related', 'action', 'accept'])
         self.cli_set(['firewall', 'global-options', 'state-policy', 'invalid', 'action', 'drop'])
 
         self.cli_set(['firewall', 'ipv6', 'name', name, 'default-action', 'drop'])
         self.cli_set(['firewall', 'ipv6', 'name', name, 'default-log'])
 
         self.cli_set(['firewall', 'ipv6', 'name', name, 'rule', '1', 'action', 'accept'])
         self.cli_set(['firewall', 'ipv6', 'name', name, 'rule', '1', 'source', 'address', '2002::1'])
         self.cli_set(['firewall', 'ipv6', 'name', name, 'rule', '1', 'destination', 'address', '2002::1:1'])
         self.cli_set(['firewall', 'ipv6', 'name', name, 'rule', '1', 'log'])
         self.cli_set(['firewall', 'ipv6', 'name', name, 'rule', '1', 'log-options', 'level', 'crit'])
 
         self.cli_set(['firewall', 'ipv6', 'forward', 'filter', 'default-action', 'accept'])
         self.cli_set(['firewall', 'ipv6', 'forward', 'filter', 'default-log'])
         self.cli_set(['firewall', 'ipv6', 'forward', 'filter', 'rule', '2', 'action', 'reject'])
         self.cli_set(['firewall', 'ipv6', 'forward', 'filter', 'rule', '2', 'protocol', 'tcp_udp'])
         self.cli_set(['firewall', 'ipv6', 'forward', 'filter', 'rule', '2', 'destination', 'port', '8888'])
         self.cli_set(['firewall', 'ipv6', 'forward', 'filter', 'rule', '2', 'inbound-interface', 'name', interface])
 
         self.cli_set(['firewall', 'ipv6', 'output', 'filter', 'default-action', 'drop'])
         self.cli_set(['firewall', 'ipv6', 'output', 'filter', 'default-log'])
         self.cli_set(['firewall', 'ipv6', 'output', 'filter', 'rule', '3', 'action', 'return'])
         self.cli_set(['firewall', 'ipv6', 'output', 'filter', 'rule', '3', 'protocol', 'gre'])
         self.cli_set(['firewall', 'ipv6', 'output', 'filter', 'rule', '3', 'outbound-interface', 'name', interface])
 
         self.cli_set(['firewall', 'ipv6', 'input', 'filter', 'rule', '3', 'action', 'accept'])
         self.cli_set(['firewall', 'ipv6', 'input', 'filter', 'rule', '3', 'protocol', 'udp'])
         self.cli_set(['firewall', 'ipv6', 'input', 'filter', 'rule', '3', 'source', 'address', '2002::1:2'])
         self.cli_set(['firewall', 'ipv6', 'input', 'filter', 'rule', '3', 'inbound-interface', 'name', interface])
 
         self.cli_commit()
 
         nftables_search = [
             ['chain VYOS_IPV6_FORWARD_filter'],
             ['type filter hook forward priority filter; policy accept;'],
             ['meta l4proto { tcp, udp }', 'th dport 8888', f'iifname "{interface}"', 'reject'],
             ['log prefix "[ipv6-FWD-filter-default-A]"','FWD-filter default-action accept', 'accept'],
             ['chain VYOS_IPV6_INPUT_filter'],
             ['type filter hook input priority filter; policy accept;'],
             ['meta l4proto udp', 'ip6 saddr 2002::1:2', f'iifname "{interface}"', 'accept'],
             ['INP-filter default-action accept', 'accept'],
             ['chain VYOS_IPV6_OUTPUT_filter'],
             ['type filter hook output priority filter; policy accept;'],
             ['meta l4proto gre', f'oifname "{interface}"', 'return'],
             ['log prefix "[ipv6-OUT-filter-default-D]"','OUT-filter default-action drop', 'drop'],
             [f'chain NAME6_{name}'],
             ['saddr 2002::1', 'daddr 2002::1:1', 'log prefix "[ipv6-NAM-v6-smoketest-1-A]" log level crit', 'accept'],
             [f'"{name} default-action drop"', f'log prefix "[ipv6-{name}-default-D]"', 'drop'],
             ['jump VYOS_STATE_POLICY6'],
             ['chain VYOS_STATE_POLICY6'],
             ['ct state established', 'accept'],
             ['ct state invalid', 'drop'],
             ['ct state related', 'accept']
         ]
 
         self.verify_nftables(nftables_search, 'ip6 vyos_filter')
 
     def test_ipv6_advanced(self):
         name = 'v6-smoketest-adv'
         name2 = 'v6-smoketest-adv2'
         interface = 'eth0'
 
         self.cli_set(['firewall', 'ipv6', 'name', name, 'default-action', 'drop'])
         self.cli_set(['firewall', 'ipv6', 'name', name, 'default-log'])
 
         self.cli_set(['firewall', 'ipv6', 'name', name, 'rule', '3', 'action', 'accept'])
         self.cli_set(['firewall', 'ipv6', 'name', name, 'rule', '3', 'packet-length', '65'])
         self.cli_set(['firewall', 'ipv6', 'name', name, 'rule', '3', 'packet-length', '513'])
         self.cli_set(['firewall', 'ipv6', 'name', name, 'rule', '3', 'packet-length', '1025'])
         self.cli_set(['firewall', 'ipv6', 'name', name, 'rule', '3', 'dscp', '18'])
         self.cli_set(['firewall', 'ipv6', 'name', name, 'rule', '3', 'dscp', '53'])
 
         self.cli_set(['firewall', 'ipv6', 'forward', 'filter', 'rule', '4', 'action', 'accept'])
         self.cli_set(['firewall', 'ipv6', 'forward', 'filter', 'rule', '4', 'packet-length', '1-1999'])
         self.cli_set(['firewall', 'ipv6', 'forward', 'filter', 'rule', '4', 'packet-length-exclude', '60000-65535'])
         self.cli_set(['firewall', 'ipv6', 'forward', 'filter', 'rule', '4', 'dscp', '4-14'])
         self.cli_set(['firewall', 'ipv6', 'forward', 'filter', 'rule', '4', 'dscp-exclude', '31-35'])
 
         self.cli_set(['firewall', 'ipv6', 'input', 'filter', 'default-action', 'accept'])
         self.cli_set(['firewall', 'ipv6', 'input', 'filter', 'rule', '1', 'source', 'address', '2001:db8::/64'])
         self.cli_set(['firewall', 'ipv6', 'input', 'filter', 'rule', '1', 'action', 'jump'])
         self.cli_set(['firewall', 'ipv6', 'input', 'filter', 'rule', '1', 'jump-target', name])
 
         self.cli_commit()
 
         nftables_search = [
             ['chain VYOS_IPV6_FORWARD_filter'],
             ['type filter hook forward priority filter; policy accept;'],
             ['ip6 length 1-1999', 'ip6 length != 60000-65535', 'ip6 dscp 0x04-0x0e', 'ip6 dscp != 0x1f-0x23', 'accept'],
             ['chain VYOS_IPV6_INPUT_filter'],
             ['type filter hook input priority filter; policy accept;'],
             ['ip6 saddr 2001:db8::/64', f'jump NAME6_{name}'],
             [f'chain NAME6_{name}'],
             ['ip6 length { 65, 513, 1025 }', 'ip6 dscp { af21, 0x35 }', 'accept'],
             [f'log prefix "[ipv6-{name}-default-D]"', 'drop']
         ]
 
         self.verify_nftables(nftables_search, 'ip6 vyos_filter')
 
     def test_ipv6_mask(self):
         name = 'v6-smoketest-mask'
         interface = 'eth0'
 
         self.cli_set(['firewall', 'group', 'ipv6-address-group', 'mask_group', 'address', '::beef'])
 
         self.cli_set(['firewall', 'ipv6', 'name', name, 'default-action', 'drop'])
         self.cli_set(['firewall', 'ipv6', 'name', name, 'default-log'])
 
         self.cli_set(['firewall', 'ipv6', 'name', name, 'rule', '1', 'action', 'drop'])
         self.cli_set(['firewall', 'ipv6', 'name', name, 'rule', '1', 'destination', 'address', '::1111:2222:3333:4444'])
         self.cli_set(['firewall', 'ipv6', 'name', name, 'rule', '1', 'destination', 'address-mask', '::ffff:ffff:ffff:ffff'])
 
         self.cli_set(['firewall', 'ipv6', 'name', name, 'rule', '2', 'action', 'accept'])
         self.cli_set(['firewall', 'ipv6', 'name', name, 'rule', '2', 'source', 'address', '!::aaaa:bbbb:cccc:dddd'])
         self.cli_set(['firewall', 'ipv6', 'name', name, 'rule', '2', 'source', 'address-mask', '::ffff:ffff:ffff:ffff'])
 
         self.cli_set(['firewall', 'ipv6', 'name', name, 'rule', '3', 'action', 'drop'])
         self.cli_set(['firewall', 'ipv6', 'name', name, 'rule', '3', 'source', 'group', 'address-group', 'mask_group'])
         self.cli_set(['firewall', 'ipv6', 'name', name, 'rule', '3', 'source', 'address-mask', '::ffff:ffff:ffff:ffff'])
 
         self.cli_commit()
 
         nftables_search = [
             ['daddr & ::ffff:ffff:ffff:ffff == ::1111:2222:3333:4444'],
             ['saddr & ::ffff:ffff:ffff:ffff != ::aaaa:bbbb:cccc:dddd'],
             ['saddr & ::ffff:ffff:ffff:ffff == @A6_mask_group']
         ]
 
         self.verify_nftables(nftables_search, 'ip6 vyos_filter')
 
     def test_ipv4_state_and_status_rules(self):
         name = 'smoketest-state'
         interface = 'eth0'
 
         self.cli_set(['firewall', 'global-options', 'state-policy', 'established', 'action', 'accept'])
         self.cli_set(['firewall', 'global-options', 'state-policy', 'related', 'action', 'accept'])
         self.cli_set(['firewall', 'global-options', 'state-policy', 'invalid', 'action', 'drop'])
 
         self.cli_set(['firewall', 'ipv4', 'name', name, 'default-action', 'drop'])
         self.cli_set(['firewall', 'ipv4', 'name', name, 'rule', '1', 'action', 'accept'])
         self.cli_set(['firewall', 'ipv4', 'name', name, 'rule', '1', 'state', 'established'])
         self.cli_set(['firewall', 'ipv4', 'name', name, 'rule', '1', 'state', 'related'])
         self.cli_set(['firewall', 'ipv4', 'name', name, 'rule', '2', 'action', 'reject'])
         self.cli_set(['firewall', 'ipv4', 'name', name, 'rule', '2', 'state', 'invalid'])
         self.cli_set(['firewall', 'ipv4', 'name', name, 'rule', '3', 'action', 'accept'])
         self.cli_set(['firewall', 'ipv4', 'name', name, 'rule', '3', 'state', 'new'])
         self.cli_set(['firewall', 'ipv4', 'name', name, 'rule', '3', 'connection-status', 'nat', 'destination'])
         self.cli_set(['firewall', 'ipv4', 'name', name, 'rule', '4', 'action', 'accept'])
         self.cli_set(['firewall', 'ipv4', 'name', name, 'rule', '4', 'state', 'new'])
         self.cli_set(['firewall', 'ipv4', 'name', name, 'rule', '4', 'state', 'established'])
         self.cli_set(['firewall', 'ipv4', 'name', name, 'rule', '4', 'connection-status', 'nat', 'source'])
         self.cli_set(['firewall', 'ipv4', 'name', name, 'rule', '5', 'action', 'accept'])
         self.cli_set(['firewall', 'ipv4', 'name', name, 'rule', '5', 'state', 'related'])
         self.cli_set(['firewall', 'ipv4', 'name', name, 'rule', '5', 'conntrack-helper', 'ftp'])
         self.cli_set(['firewall', 'ipv4', 'name', name, 'rule', '5', 'conntrack-helper', 'pptp'])
 
         self.cli_commit()
 
         nftables_search = [
             ['ct state { established, related }', 'accept'],
             ['ct state invalid', 'reject'],
             ['ct state new', 'ct status dnat', 'accept'],
             ['ct state { established, new }', 'ct status snat', 'accept'],
             ['ct state related', 'ct helper { "ftp", "pptp" }', 'accept'],
             ['drop', f'comment "{name} default-action drop"'],
             ['jump VYOS_STATE_POLICY'],
             ['chain VYOS_STATE_POLICY'],
             ['ct state established', 'accept'],
             ['ct state invalid', 'drop'],
             ['ct state related', 'accept']
         ]
 
         self.verify_nftables(nftables_search, 'ip vyos_filter')
 
         # Check conntrack
         self.verify_nftables_chain([['accept']], 'raw', 'FW_CONNTRACK')
         self.verify_nftables_chain([['return']], 'ip6 raw', 'FW_CONNTRACK')
 
     def test_bridge_basic_rules(self):
         name = 'smoketest'
         interface_in = 'eth0'
         mac_address = '00:53:00:00:00:01'
         vlan_id = '12'
         vlan_prior = '3'
 
         self.cli_set(['firewall', 'bridge', 'name', name, 'default-action', 'accept'])
         self.cli_set(['firewall', 'bridge', 'name', name, 'default-log'])
         self.cli_set(['firewall', 'bridge', 'name', name, 'rule', '1', 'action', 'accept'])
         self.cli_set(['firewall', 'bridge', 'name', name, 'rule', '1', 'source', 'mac-address', mac_address])
         self.cli_set(['firewall', 'bridge', 'name', name, 'rule', '1', 'inbound-interface', 'name', interface_in])
         self.cli_set(['firewall', 'bridge', 'name', name, 'rule', '1', 'log'])
         self.cli_set(['firewall', 'bridge', 'name', name, 'rule', '1', 'log-options', 'level', 'crit'])
 
         self.cli_set(['firewall', 'bridge', 'forward', 'filter', 'default-action', 'drop'])
         self.cli_set(['firewall', 'bridge', 'forward', 'filter', 'default-log'])
         self.cli_set(['firewall', 'bridge', 'forward', 'filter', 'rule', '1', 'action', 'accept'])
         self.cli_set(['firewall', 'bridge', 'forward', 'filter', 'rule', '1', 'vlan', 'id', vlan_id])
         self.cli_set(['firewall', 'bridge', 'forward', 'filter', 'rule', '2', 'action', 'jump'])
         self.cli_set(['firewall', 'bridge', 'forward', 'filter', 'rule', '2', 'jump-target', name])
         self.cli_set(['firewall', 'bridge', 'forward', 'filter', 'rule', '2', 'vlan', 'priority', vlan_prior])
 
         self.cli_commit()
 
         nftables_search = [
             ['chain VYOS_FORWARD_filter'],
             ['type filter hook forward priority filter; policy drop;'],
             [f'vlan id {vlan_id}', 'accept'],
             [f'vlan pcp {vlan_prior}', f'jump NAME_{name}'],
             [f'chain NAME_{name}'],
             [f'ether saddr {mac_address}', f'iifname "{interface_in}"', f'log prefix "[bri-NAM-{name}-1-A]" log level crit', 'accept']
         ]
 
         self.verify_nftables(nftables_search, 'bridge vyos_filter')
 
     def test_source_validation(self):
         # Strict
         self.cli_set(['firewall', 'global-options', 'source-validation', 'strict'])
+        self.cli_set(['firewall', 'global-options', 'ipv6-source-validation', 'strict'])
         self.cli_commit()
 
         nftables_strict_search = [
             ['fib saddr . iif oif 0', 'drop']
         ]
 
-        self.verify_nftables(nftables_strict_search, 'inet vyos_global_rpfilter')
+        self.verify_nftables_chain(nftables_strict_search, 'ip raw', 'vyos_global_rpfilter')
+        self.verify_nftables_chain(nftables_strict_search, 'ip6 raw', 'vyos_global_rpfilter')
 
         # Loose
         self.cli_set(['firewall', 'global-options', 'source-validation', 'loose'])
+        self.cli_set(['firewall', 'global-options', 'ipv6-source-validation', 'loose'])
         self.cli_commit()
 
         nftables_loose_search = [
             ['fib saddr oif 0', 'drop']
         ]
 
-        self.verify_nftables(nftables_loose_search, 'inet vyos_global_rpfilter')
+        self.verify_nftables_chain(nftables_loose_search, 'ip raw', 'vyos_global_rpfilter')
+        self.verify_nftables_chain(nftables_loose_search, 'ip6 raw', 'vyos_global_rpfilter')
 
     def test_sysfs(self):
         for name, conf in sysfs_config.items():
             paths = glob(conf['sysfs'])
             for path in paths:
                 with open(path, 'r') as f:
                     self.assertEqual(f.read().strip(), conf['default'], msg=path)
 
             self.cli_set(['firewall', 'global-options', name.replace("_", "-"), conf['test_value']])
 
         self.cli_commit()
 
         for name, conf in sysfs_config.items():
             paths = glob(conf['sysfs'])
             for path in paths:
                 with open(path, 'r') as f:
                     self.assertNotEqual(f.read().strip(), conf['default'], msg=path)
 
 ### Zone
     def test_zone_basic(self):
         self.cli_set(['firewall', 'ipv4', 'name', 'smoketest', 'default-action', 'drop'])
         self.cli_set(['firewall', 'zone', 'smoketest-eth0', 'interface', 'eth0'])
         self.cli_set(['firewall', 'zone', 'smoketest-eth0', 'from', 'smoketest-local', 'firewall', 'name', 'smoketest'])
         self.cli_set(['firewall', 'zone', 'smoketest-local', 'local-zone'])
         self.cli_set(['firewall', 'zone', 'smoketest-local', 'from', 'smoketest-eth0', 'firewall', 'name', 'smoketest'])
         self.cli_set(['firewall', 'global-options', 'state-policy', 'established', 'action', 'accept'])
         self.cli_set(['firewall', 'global-options', 'state-policy', 'established', 'log'])
         self.cli_set(['firewall', 'global-options', 'state-policy', 'related', 'action', 'accept'])
         self.cli_set(['firewall', 'global-options', 'state-policy', 'invalid', 'action', 'drop'])
 
         self.cli_commit()
 
         nftables_search = [
             ['chain VYOS_ZONE_FORWARD'],
             ['type filter hook forward priority filter + 1'],
             ['chain VYOS_ZONE_OUTPUT'],
             ['type filter hook output priority filter + 1'],
             ['chain VYOS_ZONE_LOCAL'],
             ['type filter hook input priority filter + 1'],
             ['chain VZONE_smoketest-eth0'],
             ['chain VZONE_smoketest-local_IN'],
             ['chain VZONE_smoketest-local_OUT'],
             ['oifname "eth0"', 'jump VZONE_smoketest-eth0'],
             ['jump VZONE_smoketest-local_IN'],
             ['jump VZONE_smoketest-local_OUT'],
             ['iifname "eth0"', 'jump NAME_smoketest'],
             ['oifname "eth0"', 'jump NAME_smoketest'],
             ['jump VYOS_STATE_POLICY'],
             ['chain VYOS_STATE_POLICY'],
             ['ct state established', 'log prefix "[STATE-POLICY-EST-A]"', 'accept'],
             ['ct state invalid', 'drop'],
             ['ct state related', 'accept']
         ]
 
         nftables_output = cmd('sudo nft list table ip vyos_filter')
 
         for search in nftables_search:
             matched = False
             for line in nftables_output.split("\n"):
                 if all(item in line for item in search):
                     matched = True
                     break
             self.assertTrue(matched)
 
     def test_flow_offload(self):
         self.cli_set(['firewall', 'flowtable', 'smoketest', 'interface', 'eth0'])
         self.cli_set(['firewall', 'flowtable', 'smoketest', 'offload', 'hardware'])
 
         # QEMU virtual NIC does not support hw-tc-offload
         with self.assertRaises(ConfigSessionError):
             self.cli_commit()
 
         self.cli_set(['firewall', 'flowtable', 'smoketest', 'offload', 'software'])
 
         self.cli_set(['firewall', 'ipv4', 'forward', 'filter', 'rule', '1', 'action', 'offload'])
         self.cli_set(['firewall', 'ipv4', 'forward', 'filter', 'rule', '1', 'offload-target', 'smoketest'])
         self.cli_set(['firewall', 'ipv4', 'forward', 'filter', 'rule', '1', 'protocol', 'tcp_udp'])
         self.cli_set(['firewall', 'ipv4', 'forward', 'filter', 'rule', '1', 'state', 'established'])
         self.cli_set(['firewall', 'ipv4', 'forward', 'filter', 'rule', '1', 'state', 'related'])
 
         self.cli_set(['firewall', 'ipv6', 'forward', 'filter', 'rule', '1', 'action', 'offload'])
         self.cli_set(['firewall', 'ipv6', 'forward', 'filter', 'rule', '1', 'offload-target', 'smoketest'])
         self.cli_set(['firewall', 'ipv6', 'forward', 'filter', 'rule', '1', 'protocol', 'tcp_udp'])
         self.cli_set(['firewall', 'ipv6', 'forward', 'filter', 'rule', '1', 'state', 'established'])
         self.cli_set(['firewall', 'ipv6', 'forward', 'filter', 'rule', '1', 'state', 'related'])
 
         self.cli_commit()
 
         nftables_search = [
             ['flowtable VYOS_FLOWTABLE_smoketest'],
             ['hook ingress priority filter'],
             ['devices = { eth0 }'],
             ['ct state { established, related }', 'meta l4proto { tcp, udp }', 'flow add @VYOS_FLOWTABLE_smoketest'],
         ]
 
         self.verify_nftables(nftables_search, 'ip vyos_filter')
         self.verify_nftables(nftables_search, 'ip6 vyos_filter')
 
         # Check conntrack
         #self.verify_nftables_chain([['accept']], 'ip vyos_conntrack', 'FW_CONNTRACK')
         #self.verify_nftables_chain([['accept']], 'ip6 vyos_conntrack', 'FW_CONNTRACK')
 
     def test_zone_flow_offload(self):
         self.cli_set(['firewall', 'flowtable', 'smoketest', 'interface', 'eth0'])
         self.cli_set(['firewall', 'flowtable', 'smoketest', 'offload', 'hardware'])
 
         # QEMU virtual NIC does not support hw-tc-offload
         with self.assertRaises(ConfigSessionError):
             self.cli_commit()
 
         self.cli_set(['firewall', 'flowtable', 'smoketest', 'offload', 'software'])
 
         self.cli_set(['firewall', 'ipv4', 'name', 'smoketest', 'rule', '1', 'action', 'offload'])
         self.cli_set(['firewall', 'ipv4', 'name', 'smoketest', 'rule', '1', 'offload-target', 'smoketest'])
 
         self.cli_set(['firewall', 'ipv6', 'name', 'smoketest', 'rule', '1', 'action', 'offload'])
         self.cli_set(['firewall', 'ipv6', 'name', 'smoketest', 'rule', '1', 'offload-target', 'smoketest'])
 
         self.cli_commit()
 
         nftables_search = [
             ['chain NAME_smoketest'],
             ['flow add @VYOS_FLOWTABLE_smoketest']
         ]
 
         self.verify_nftables(nftables_search, 'ip vyos_filter')
 
         nftables_search = [
             ['chain NAME6_smoketest'],
             ['flow add @VYOS_FLOWTABLE_smoketest']
         ]
 
         self.verify_nftables(nftables_search, 'ip6 vyos_filter')
 
         # Check conntrack
         #self.verify_nftables_chain([['accept']], 'ip vyos_conntrack', 'FW_CONNTRACK')
         #self.verify_nftables_chain([['accept']], 'ip6 vyos_conntrack', 'FW_CONNTRACK')
 
 if __name__ == '__main__':
     unittest.main(verbosity=2)