Re: RFC: Can the NFS code determine what NIC will be used?

Zhenlei Huang <[email protected]>
Newsgroups gmane.os.freebsd.devel.net
Message-ID <[email protected]>

> On Jan 30, 2026, at 7:27 AM, Rick Macklem <[email protected]> wrote:
> 
> On Tue, Jan 27, 2026 at 7:00 PM Zhenlei Huang <[email protected] <mailto:[email protected]>> wrote:
>> 
>> 
>> 
>>> On Jan 28, 2026, at 8:03 AM, Rick Macklem <[email protected]> wrote:
>>> 
>>> Hi,
>>> 
>>> Basically, the subject line says it all.
>>> 
>>> I am wondering if the NFS/krpc code (send side) can
>>> determine what NIC will be used to send the RPC message.
>>> 
>>> Why?
>>> 
>>> Right now, the NFS code fills the RPC message into
>>> M_EXTPG mbufs for the KTLS case only.
>>> However, some NICs (Chelsio and Mellanox?) can
>>> handle M_EXTPG mbufs, as indicated by the
>>> IFCAP_MEXTPG flag being set.
>>> 
>>> As such, it would be nice if the NFS/krpc code could
>>> determine if IFCAP_MEXTPG is set, so that it can
>>> use M_EXTPG mbufs.
>>> --> Yes, for other NICs, the mbuf chain will be copied
>>>     in ip_output() by calling mb_unmapped_to_ext(),
>>>     so they work, but I don't see any reason to fill the
>>>     RPC message into M_EXTPG mbufs if ip_output()
>>>     just ends up copying them?
>>> 
>>> The NFS/krpc code does know the IP host address of the
>>> other end, so I think the question becomes "can the NFS/krpc
>>> code do a routing call to find out what NIC will be used?".
>> 
>> Given the dest IP address is known, you can find the nexthop
>> info from fib4_lookup() and then extract the ifnet from the nexthop
>> info. The usage of fib4_lookup() in ip_output() is a good example.
> Thanks! It seems to work for a simple test case.
> 
> However, I do have a couple of questions.
> My test uses so_fibnum and inp_flowid. Are these the correct place
> to get these arguments, when done on a TCP socket just after a connect?

I think yes.

> 
> And for IPv6, I assume I use fib6_lookup()?

Yes.

> --> My question is, do I first call in6_splitscope() to get the correct address
>     argument and scopeid? (I know nothing about IPv6;-)
>     (I don't even know if the destination address for an NFS connection will
>      have a scopeid?)

For the scopeid, it is required for IPv6 link-local address. So if the destination address for an NFS connection is
link-local address, then yes in6_splitscope() should be called to get correct scopeid. PS, currently the
scopeid is embedded into `struct in6_addr` and re-use some high bits.

> 
> Thanks for your help, rick

You're welcome !

> 
>> 
>>> 
>>> Thanks for any info, rick
>>> 
>>> Thanks for any info, rick
>>> 
>> 
>> Best regards,
>> Zhenlei

Best regards,
Zhenlei
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.