]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/commit
firewall: Revert strict martian check on loopback interface
authorArne Fitzenreiter <arne_f@ipfire.org>
Mon, 14 Feb 2022 16:32:27 +0000 (17:32 +0100)
committerArne Fitzenreiter <arne_f@ipfire.org>
Mon, 14 Feb 2022 19:47:37 +0000 (19:47 +0000)
commit4b94860d07b5124e90711c802e87cce8547c3043
treea72814ae080d44932fe95edf84ff749cc8918442
parentea72759c97e051dc3ca42a4aded55f28a9df7f49
firewall: Revert strict martian check on loopback interface

If the firewall is talking to itself using one of its private IP
addresses (e.g. the primary green interface IP address), it will use the
loopback interface.

This is due to the local routing table which will be looked up first:

  [root@ipfire ~]# ip rule
  0:      from all lookup local
  128:    from all lookup 220
  220:    from all lookup 220
  32765:  from all lookup static
  32766:  from all lookup main
  32767:  from all lookup default

It contains:

  [root@ipfire ~]# ip route show table local
  local 8x.1x.1x.1x dev ppp0 proto kernel scope host src 8x.1x.1x.1x
  local 127.0.0.0/8 dev lo proto kernel scope host src 127.0.0.1
  local 127.0.0.1 dev lo proto kernel scope host src 127.0.0.1
  broadcast 127.255.255.255 dev lo proto kernel scope link src 127.0.0.1
  local 192.168.x.1 dev green0 proto kernel scope host src 192.168.x.1
  broadcast 192.168.x.255 dev green0 proto kernel scope link src 192.168.x.1

Any lookup for the green IP address will show this:

  local 192.168.x.1 dev lo table local src 192.168.x.1 uid 0
      cache <local>

A test ping shows this in tcpdump:

  [root@ipfire ~]# tcpdump -i any icmp -nn
  tcpdump: data link type LINUX_SLL2
  tcpdump: verbose output suppressed, use -v[v]... for full protocol decode
  listening on any, link-type LINUX_SLL2 (Linux cooked v2), snapshot length 262144 bytes
  17:24:22.864293 lo    In  IP 127.0.0.1 > 127.0.0.1: ICMP echo request, id 10420, seq 1, length 64
  17:24:22.864422 lo    In  IP 127.0.0.1 > 127.0.0.1: ICMP echo reply, id 10420, seq 1, length 64
  17:24:29.162021 lo    In  IP 192.168.x.1 > 192.168.x.1: ICMP echo request, id 1555, seq 1, length 64
  17:24:29.162201 lo    In  IP 192.168.x.1 > 192.168.x.1: ICMP echo reply, id 1555, seq 1, length 64

For this reason, we will have to accept any source and destination IP
address on the loopback interface, which is what this patch does.

We can however, continue to check whether we received any packets with
the loopback address on any other interface.

This regression was introduced in commit a36cd34e.

Fixes: #12776 - New spoofed or martian filter block
Signed-off-by: Arne Fitzenreiter <arne_f@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Reviewed-by: Peter Müller <peter.mueller@ipfire.org>
Signed-off-by: Arne Fitzenreiter <arne_f@ipfire.org>
src/initscripts/system/firewall