netlink: Generate ICMP correctly if point-to-point
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 3 May 2014 11:04:32 +0000 (12:04 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 3 May 2014 15:40:31 +0000 (16:40 +0100)
commit826b47e921488742fd77f31352fa04df3a5d0e11
treeb40abb883f61d554f229fbb54a9c7f46a6de9aa4
parent091433c62a7e2fdb12f60d2468c5f98b9603f429
netlink: Generate ICMP correctly if point-to-point

In point-to-point configurations, we need to make sure that ICMP we
generate (a) has the right source address (we have to borrow the
address of the peer or the local host, depending) and (b) is delivered
in the right direction (back to wherever the bad packet came from).

To this end netlink_icmp_tmpl now takes an explicit ICMP source
address parameter, for netlink_icmp_simple to provide the correct
address.

We replicate a small amount of logic from netlink_incoming (the choice
between netlink_client_deliver, netlink_host_deliver, and
netlink_packet_forward/netlink_packet_deliver).  But netlink_incoming
is not suitable because it is intended only for packets from outside
secnet.  For example, in a non-ptp configuration it will reject
packets whose source address is secnet's address.  And writing it out
again is arguably clearer anyway.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
netlink.c