Skip to content

Commit 4753c8d

Browse files
committed
ospfv2: use ipi_spec_dst for the outgoing source address
On send, the kernel reads the source address from the ipi_spec_dst field of in_pktinfo, not ipi_addr (which is only meaningful on receive). Writing it to ipi_addr made the kernel choose the source itself, which can differ from the address Holo selected when the interface has multiple addresses. Signed-off-by: Renato Westphal <renatowestphal@gmail.com>
1 parent 9e0f194 commit 4753c8d

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

holo-ospf/src/ospfv2/network.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,10 @@ impl NetworkVersion<Self> for Ospfv2 {
124124
fn new_pktinfo(src: Ipv4Addr, ifindex: u32) -> libc::in_pktinfo {
125125
libc::in_pktinfo {
126126
ipi_ifindex: ifindex as i32,
127-
ipi_spec_dst: libc::in_addr { s_addr: 0 },
128-
ipi_addr: libc::in_addr { s_addr: src.into() },
127+
ipi_spec_dst: libc::in_addr {
128+
s_addr: u32::from_ne_bytes(src.octets()),
129+
},
130+
ipi_addr: libc::in_addr { s_addr: 0 },
129131
}
130132
}
131133

0 commit comments

Comments
 (0)