for(unit = WAN_UNIT_FIRST; unit < wan_max_unit; ++unit){
                if(!is_wan_connect(unit))
                        continue;
                snprintf(prefix, sizeof(prefix), "wan%d_", unit);
                wan_if = get_wan_ifname(unit);
                wanx_if = nvram_safe_get(strcat_r(prefix, "ifname", tmp));
                wanx_ip = nvram_safe_get(strcat_r(prefix, "xipaddr", tmp));
#ifdef RTCONFIG_TAGGED_BASED_VLAN
        /* Write forward rule for vlan */
        vlan_subnet_filter_forward(fp, wan_if);
#endif
#ifdef RTCONFIG_AMAS_WGN
        wgn_filter_forward(fp, wan_if);
#endif
// ~ oleg patch
                /* Filter out invalid WAN->WAN connections */
                fprintf(fp, "-A FORWARD -o %s ! -i %s -j %s\n", wan_if, lan_if, "other2wan");
#ifdef RTCONFIG_IPV6
                 if (ipv6_enabled() && *wan6face) {
                        if (nvram_match("ipv6_fw_enable", "1")) {
                                fprintf(fp_ipv6, "-A FORWARD -o %s -i %s -j %s\n", wan6face, lan_if, logaccept);
                        } else {        // The default DROP rule from the IPv6 firewall would take care of it
                        fprintf(fp_ipv6, "-A FORWARD -o %s ! -i %s -j %s\n", wan6face, lan_if, logdrop);
                        }
                }
#endif
                if (strcmp(wanx_if, wan_if) && inet_addr_(wanx_ip) && dualwan_unit__nonusbif(unit))
                        fprintf(fp, "-A FORWARD -o %s ! -i %s -j %s\n", wanx_if, lan_if, "other2wan");
        }