(brname)
| 1278 | |
| 1279 | |
| 1280 | def add_fw_framework(brname): |
| 1281 | try: |
| 1282 | execute("modprobe br_netfilter") |
| 1283 | except: |
| 1284 | logging.debug("failed to load kernel module br_netfilter") |
| 1285 | |
| 1286 | try: |
| 1287 | execute("sysctl -w net.bridge.bridge-nf-call-arptables=1") |
| 1288 | execute("sysctl -w net.bridge.bridge-nf-call-iptables=1") |
| 1289 | execute("sysctl -w net.bridge.bridge-nf-call-ip6tables=1") |
| 1290 | except: |
| 1291 | logging.warn("failed to turn on bridge netfilter") |
| 1292 | |
| 1293 | brfw = get_br_fw(brname) |
| 1294 | try: |
| 1295 | execute("iptables -L " + brfw) |
| 1296 | except: |
| 1297 | execute("iptables -N " + brfw) |
| 1298 | |
| 1299 | brfwout = brfw + "-OUT" |
| 1300 | try: |
| 1301 | execute("iptables -L " + brfwout) |
| 1302 | except: |
| 1303 | execute("iptables -N " + brfwout) |
| 1304 | |
| 1305 | brfwin = brfw + "-IN" |
| 1306 | try: |
| 1307 | execute("iptables -L " + brfwin) |
| 1308 | except: |
| 1309 | execute("iptables -N " + brfwin) |
| 1310 | |
| 1311 | try: |
| 1312 | execute('ip6tables -L ' + brfw) |
| 1313 | except: |
| 1314 | execute('ip6tables -N ' + brfw) |
| 1315 | |
| 1316 | brfwout = brfw + "-OUT" |
| 1317 | try: |
| 1318 | execute('ip6tables -L ' + brfwout) |
| 1319 | except: |
| 1320 | execute('ip6tables -N ' + brfwout) |
| 1321 | |
| 1322 | brfwin = brfw + "-IN" |
| 1323 | try: |
| 1324 | execute('ip6tables -L ' + brfwin) |
| 1325 | except: |
| 1326 | execute('ip6tables -N ' + brfwin) |
| 1327 | |
| 1328 | physdev = get_bridge_physdev(brname) |
| 1329 | |
| 1330 | try: |
| 1331 | refs = int(execute("""iptables -n -L %s | awk '/%s(.*)references/ {gsub(/\(/, "") ;print $3}'""" % (brfw,brfw)).strip()) |
| 1332 | refs_in = int(execute("""iptables -n -L %s-IN | awk '/%s-IN(.*)references/ {gsub(/\(/, "") ;print $3}'""" % (brfw,brfw)).strip()) |
| 1333 | refs_out = int(execute("""iptables -n -L %s-OUT | awk '/%s-OUT(.*)references/ {gsub(/\(/, "") ;print $3}'""" % (brfw,brfw)).strip()) |
| 1334 | refs6 = int(execute("""ip6tables -n -L %s | awk '/%s(.*)references/ {gsub(/\(/, "") ;print $3}'""" % (brfw,brfw)).strip()) |
| 1335 | |
| 1336 | if refs == 0 or refs_in == 0 or refs_out == 0: |
| 1337 | execute("iptables -I FORWARD -i " + brname + " -j DROP") |
no test coverage detected