Preventing ng_callout() timeouts to trigger packet queuing

Adrian Chadd adrian at freebsd.org
Thu Apr 10 01:09:54 UTC 2014


Hi!

Would you mind filing a PR for this?

www.freebsd.org/send-pr.html

That way it won't (hopefully!) get lost.

Thanks!


-a


On 9 April 2014 14:25, Karim Fodil-Lemelin <fodillemlinkarim at gmail.com> wrote:
> Hi,
>
> Below is a revised patch for this issue. It accounts for nodes or hooks that
> explicitly need to be queuing:
>
> @@ -3632,7 +3632,12 @@ ng_callout(struct callout *c, node_p node, hook_p
> hook, int ticks,
>
>         if ((item = ng_alloc_item(NGQF_FN, NG_NOFLAGS)) == NULL)
>                 return (ENOMEM);
>
> -       item->el_flags |= NGQF_WRITER;
> +       if ((node->nd_flags & NGF_FORCE_WRITER) ||
> +           (hook && (hook->hk_flags & HK_FORCE_WRITER)))
>
> +         item->el_flags |= NGQF_WRITER;
> +       else
>
> +         item->el_flags |= NGQF_READER;
> +
>         NG_NODE_REF(node);              /* and one for the item */
>         NGI_SET_NODE(item, node);
>         if (hook) {
>
> Regards,
>
> Karim.
>
>
> On 09/04/2014 3:16 PM, Karim Fodil-Lemelin wrote:
>>
>> Hi List,
>>
>> I'm calling out to the general wisdom ... I have seen an issue in netgraph
>> where, if called, a callout routine registered by ng_callout() will trigger
>> packet queuing inside the worklist of netgraph since ng_callout() makes my
>> node suddenly a WRITER node (therefore non reentrant) for the duration of
>> the call.
>>
>> So as soon as the callout function returns, all following packets will get
>> directly passed to the node again and when the ngintr thread gets executed
>> then only then will I get the queued packets. This introduces out of order
>> packets in the flow. I am using the current patch below to solve the issue
>> and I am wondering if there is anything wrong with it (and maybe contribute
>> back :):
>>
>>
>> @@ -3632,7 +3632,7 @@ ng_callout(struct callout *c, node_p node, hook_p
>> hook, int ticks,
>>         if ((item = ng_alloc_item(NGQF_FN, NG_NOFLAGS)) == NULL)
>>                 return (ENOMEM);
>>
>> -       item->el_flags |= NGQF_WRITER;
>> +       item->el_flags = NGQF_READER;
>>         NG_NODE_REF(node);              /* and one for the item */
>>         NGI_SET_NODE(item, node);
>>         if (hook) {
>>
>>
>> Best regards,
>>
>> Karim.
>> _______________________________________________
>> freebsd-net at freebsd.org mailing list
>> http://lists.freebsd.org/mailman/listinfo/freebsd-net
>> To unsubscribe, send any mail to "freebsd-net-unsubscribe at freebsd.org"
>
>
> _______________________________________________
> freebsd-net at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-net
> To unsubscribe, send any mail to "freebsd-net-unsubscribe at freebsd.org"


More information about the freebsd-net mailing list