I open a TAP device using
p->fd = open("/dev/net/tun", O_RDWR);
ifr.ifr_flags = IFF_TAP | IFF_ONE_QUEUE | IFF_NO_PI;
strncpy(ifr.ifr_name, p->name, IFNAMSIZ-1);
result = ioctl(p->fd, TUNSETIFF, &ifr);
ifr.ifr_flags = (IFF_UP | IFF_RUNNING);
result = ioctl(dummySock, SIOCSIFFLAGS, &ifr);
The problem I ran into is when an application (like mozilla) wants to send a packet through a tap device, it needs to get the dst mac address. Thus, the kernel sends an ARP request. The application I am writing redirects an arp request (via a raw socket on a physical device) and receives an arp response. This arp response is sent back to the crane device, but the kernel refuses to accept it. If I add the arp entry manually, the arp request will not be created, and there is a two-way ip exchange (mozilla glad).
Wireshark . ICMPv6 ( ). , , . ARP/ICMP.
: arp reply/ICMPv6? ioctl, ?
Edit:
( tshark) "ethgress" ,
9 16.548328 fc00:1::2 -> ff02::1:ff00:1 ICMPv6 86 Neighbor Solicitation
10 17.243247 fc00:1::100 -> fc00:1::2 ICMPv6 86 Neighbor Advertisement
11 17.548652 fc00:1::2 -> ff02::1:ff00:1 ICMPv6 86 Neighbor Solicitation
12 17.668736 fc00:1::100 -> fc00:1::2 ICMPv6 86 Neighbor Advertisement
ifconfig "ethgress"
ethgress Link encap:Ethernet HWaddr 00:01:02:03:04:05
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:83 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:10000
RX bytes:0 (0.0 b) TX bytes:7062 (6.8 KiB)
, ICMPv6 . tx .
"ethgress" IPv6 fc00: 1:: 2, fc00: 1:: 1. fc00: 1:: 1 , fc00: 1:100, ( ip fc00: 1:: 1 ) mac. Tcpdump , wirehark/tshark . Rx arp. ARP-.
2:
. , . . . , , . TAP. IP-. TAP IPv4, IPv6. , mozilla, . ARP-/ . . ARP ARP, TAP. arp tcpdump, arp. MAC- TAP .
.
cat /proc/sys/net/ipv4/conf/all/log_martians
0
cat /proc/sys/net/ipv4/conf/all/rp_filter
1
cat /proc/sys/net/ipv4/conf/all/arp_filter
0