Project Home
Project Home
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Interface specific hooks of protocol driver (lsm-XXX.so) attached with PFIL_TYPE_IFNET are broken in QNX 7: (4 Items)
   
Interface specific hooks of protocol driver (lsm-XXX.so) attached with PFIL_TYPE_IFNET are broken in QNX 7  
Hi,

we are a provider of Industrial Ethernet protocol stack solutions. For the required
high performance low latency communication we have developed an own protocol driver
similar to your "lsm-nraw" which runs in the stack context to bypass the IP layer
but with a much more optimized data exchange to the application. We are using this
implementation on all 6.x versions since QNX 6.4 without any problems. Unfortunately
our implementation seems to be broken in QNX 7 although it is compiled without any
errors.

In our implementation we call pfil_head_get(int af, u_long dlt) with af set to PFIL_TYPE_IFNET
to indicate an interface hook and dlt set to the respective interface pointer according
to http://www.qnx.com/developers/docs/6.4.1/io-pkt_en/user_guide/filtering.html.

Now I have two initial concerns/questions:

1. The interface pointer has to be casted to u_long which obviously is a little bit fishy
   on a 64 bit architecture.

2. At some point in time QNX introduced so called Forwarding Information Base (FIB)
   support which is documented poorly or more or less not at all. In the header <pfil.h> which
   is included to build our protocol driver the define QNX_MFIB changes the
   hook prototype as first argument of pfil_add_hook() from
   
   int (*func)(void *, struct mbuf **, struct ifnet *, int)
   
     into
   
   int (*func)(void *, struct mbuf **, struct ifnet *, int, int)
   
   The last parameter seems to be FIB related. How can one figure out at compile time
   how QNX is built or where is this build option for the different QNX versions
   documented ?
   
All this are more or less oddnesses one can overcome but starting with QNX 7 the hook
does not seem to be called at all. After several hours of investigation we changed our
implementation to hook with pfil_head_get(PFIL_TYPE_IFT, IFT_ETHER) instead of the interface
specific implementation PFIL_TYPE_IFNET mentioned above and this is still working on
QNX 7 with the obvious drawback that we have to handle all mbufs which are not for our
interface, too.

Now we got curious and analyzed the ether_input() routine where both hooks are handled.
Compared to earlier implementations again the FIB support seems to make the difference.
In previous QNX versions the hooks get called unconditionally but now a call to
if_get_next_fib() is performed before a hook is called. The 2nd parameter of this
call is a so called start_fib which is initialized to -1 before the call to the hooks
which are attached with PFIL_TYPE_IFT. The if_get_next_fib() is called again before
the hooks attached with PFIL_TYPE_IFNET are called but this time the start_fib is not
reset to -1 again but has the value returned from the previous call (which is 16). This causes
the call to return with 17 and to skip the execution of the PFIL_TYPE_IFNET hooks.

3 . My 3rd an most important question is if you have ever tested the interface specific
    hooks attached with PFIL_TYPE_IFNET on QNX 7 and if they run in any of your lsm-xxx.so
    protocol drivers is there anything special to do (with respect to FIBs ???) to make
    our implementation work in the same way as on 6.x.

Unfortunately we have no kernel code insight so all the results above are based on the
analysis of machine code level debugging sessions.

Best regards,

  Oliver
Re: Interface specific hooks of protocol driver (lsm-XXX.so) attached with PFIL_TYPE_IFNET are broken in QNX 7  
Hi Oliver,
We found and resolved this issue in January with the interface hook not being called when it should. Please get in touch
 with your support contact and ask about issue ID 2665276 COREOS-114498 and they should be able to provide you with an 
updated io-pkt that resolves this.
Regards,
Nick
Re: Interface specific hooks of protocol driver (lsm-XXX.so) attached with PFIL_TYPE_IFNET are broken in QNX 7  
Hi Nick,

thank you for your fast reply and valuable answer. But our affected products are a middleware (protocol stacks) which 
are installed on customer systems and the customer will develop it's application on top. Especially for our customers 
who are in the process to upgrade existing 6.x installations to 7.x it would be a little bit surprising to tell them 
they need a newer io-pkt they have to request with the ID mentioned in your mail. I wonder when this modified version 
will be distributed on more common channels like the QNX Software Center so we can write in our prerequisites for our 
product you need at least to update your io-pkt on QNX 7 to version x.y.z.

Can you also give a short statement to the related ambiguities mentioned in question 1 and 2 of my initial post.

Best regards,

  Oliver
Re: Interface specific hooks of protocol driver (lsm-XXX.so) attached with PFIL_TYPE_IFNET are broken in QNX 7  
Hi Oliver,
Please get in touch with your support contact, they should be able to help you with roll out plans for this fix. Fixes 
are normally released through QNX Software Center, either customer specific or general release.

For your earlier questions:
1) There is no issue with casting a pointer to a u_long as QNX uses LP64 on 64 bit (and ILP32 on 32 bit)
http://www.qnx.com/developers/docs/7.0.0/#com.qnx.doc.neutrino.prog/topic/64bits_data_types.html

2) Unfortunately there isn't an easy way for a customer to determine the exact flags that were used to build the io-pkt 
binary. If you have source level access then you would be able to see the common.mk files and see that they contain a 
define for QNX_MFIB.

Regards,
Nick