ILD

tentative ipv6 address地址问题
作者:Yuan Jianpeng 邮箱:yuanjp89@163.com
发布时间:2023-8-7 站点:Inside Linux Development

最近在做ipv6拨号,需要发送router solicitation。发送rs需要接口的link local地址ok.

linux内核只有在接口首次变成IFF_RUNNING的时候,才会配置link local地址。


在fedora 35中,一个realtek的有线网卡,在插入网线的时候,状态变成IFF_RUNNING

因此监听RTMGRP_LINK事件,在接口up的时候,创建套接字发送rs. 但是发送失败:

send router solicitation failed: Cannot assign requested address

send router solicitation failed, ifname enp4s0


检查发现,是有地址的。

2: enp4s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000                                        link/ether 00:00:00:63:24:e3 brd ff:ff:ff:ff:ff:ff permaddr fc:34:97:b8:b2:42                                                                                                       

    inet6 fe80::200:ff:fe63:24e3/64 scope link tentative                                                                                                                                       

       valid_lft forever preferred_lft forever  


手动写一个demo,相同的代码可以发送成功。最后发现,原来内核刚配置的link local地址是tentative的。如上,需要等待一会才可以。

可能是内核在做DAD (duplicate address detection)。



Copyright © linuxdev.cc 2017-2024. Some Rights Reserved.