You can probably steal the code from slaacd(8).

On 23 February 2024 20:58:59 CET, Claudio Jeker <cje...@diehard.n-r-g.com> 
wrote:
>On Fri, Feb 23, 2024 at 06:25:18PM +0100, Denis Fondras wrote:
>> Hello,
>> 
>> I am trying to add IPv6 support for pppd(8) (IPv6CP) and I encounter a 
>> blocker
>> when adding a default IPv6 route to PPP peer.
>> 
>> Feb 23 17:26:45 rt-01 pppd[64071]: Couldn't add IPv6 default route: Network 
>> is unreachable
>> 
>> Adding the default route from route(8) works when the connection is 
>> established.
>> 
>> From what I see with route(8), it sends the same route message as pppd(8).
>> 
>> From `route -v add -inet6 default fe80::ca4c:75ff:fe16:9f00%ppp0` :
>> 
>> ```
>> RTM_ADD: Add Route: len 168, priority 0, table 0, if# 0, pid: 0, seq 1, 
>> errno 0
>> flags:<UP,GATEWAY>
>> fmask:
>> use:        0   mtu:        0    expire:        0 
>> locks:  inits: 
>> sockaddrs: <DST,GATEWAY,NETMASK>
>>  :: fe80::ca4c:75ff:fe16:9f00%ppp0 default
>> ```
>> 
>> From pppd(8) :
>> ```
>> got message of size 168 on Fri Feb 23 17:26:45 2024
>> RTM_ADD: Add Route: len 168, priority 0, table 0, if# 0, pid: 64071, seq 1, 
>> errno 51
>> flags:<UP,GATEWAY>
>> fmask:
>> use:        0   mtu:        0    expire:        0 
>> locks:  inits: 
>> sockaddrs: <DST,GATEWAY,NETMASK>
>>  :: fe80::ca4c:75ff:fe16:9f00%ppp0 default
>> ```
>> 
>> However `route monitor -inet6` shows that the message is different when using
>> route(8) :
>> ```
>> got message of size 288 on Fri Feb 23 17:26:22 2024
>> RTM_ADD: Add Route: len 288, priority 56, table 0, if# 7, name ppp0, pid: 
>> 53003, seq 1, errno 0
>> flags:<UP,GATEWAY,DONE>
>> fmask:
>> use:        0   mtu:        0    expire:        0 
>> locks:  inits: 
>> sockaddrs: <DST,GATEWAY,NETMASK,IFP,IFA,BRD>
>>  :: fe80::ca4c:75ff:fe16:9f00%ppp0 :: ppp0 fe80::d925:b01f:db25:b020%ppp0 
>> fe80::ca4c:75ff:fe16:9f00%ppp0
>> ```
>> 
>> Should I also send the IFP, IFA and BRD sockaddrs from pppd(8) ?
>
>Don't think so.
>
>> How comes message sent from route(8) have more attributes when received by
>> monitor ?
>
>The kernel fills those in.
>
>Make sure you encode the IPv6 link local address correctly. The stupid
>kame hack will hunt you.

-- 
Sent from a mobile device. Please excuse poor formatting.

Reply via email to