Date: Tue, 9 Jun 2009 23:05:29 GMT From: Marko Zec <zec@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 163941 for review Message-ID: <200906092305.n59N5TrV002295@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=163941 Change 163941 by zec@zec_amdx4 on 2009/06/09 23:05:04 A still nonfunctional hack aiming at preventing inbound path of the network stack being called directly from the outbound path via netgraph. Affected files ... .. //depot/projects/vimage-commit2/src/sys/netgraph/netgraph.h#25 edit .. //depot/projects/vimage-commit2/src/sys/netgraph/ng_base.c#33 edit .. //depot/projects/vimage-commit2/src/sys/netgraph/ng_eiface.c#23 edit .. //depot/projects/vimage-commit2/src/sys/sys/proc.h#18 edit Differences ... ==== //depot/projects/vimage-commit2/src/sys/netgraph/netgraph.h#25 (text+ko) ==== @@ -130,6 +130,8 @@ #define HK_FORCE_WRITER 0x0004 /* Incoming data queued as a writer */ #define HK_DEAD 0x0008 /* This is the dead hook.. don't free */ #define HK_HI_STACK 0x0010 /* Hook has hi stack usage */ +#define HK_TO_INBOUND 0x0020 /* Hook calls into the inbound path + of the network stack. */ /* * Public Methods for hook @@ -150,6 +152,8 @@ #define _NG_HOOK_FORCE_WRITER(hook) \ do { hook->hk_flags |= HK_FORCE_WRITER; } while (0) #define _NG_HOOK_FORCE_QUEUE(hook) do { hook->hk_flags |= HK_QUEUE; } while (0) +#define _NG_HOOK_SET_TO_INBOUND(hook) \ + do { hook->hk_flags |= HK_TO_INBOUND; } while (0) #define _NG_HOOK_HI_STACK(hook) do { hook->hk_flags |= HK_HI_STACK; } while (0) /* Some shortcuts */ @@ -176,8 +180,11 @@ static __inline node_p _ng_hook_node(hook_p hook, char * file, int line); static __inline hook_p _ng_hook_peer(hook_p hook, char * file, int line); static __inline void _ng_hook_force_writer(hook_p hook, char * file, - int line); -static __inline void _ng_hook_force_queue(hook_p hook, char * file, int line); + int line); +static __inline void _ng_hook_force_queue(hook_p hook, char * file, + int line); +static __inline void _ng_hook_set_to_inbound(hook_p hook, char * file, + int line); static __inline void _chkhook(hook_p hook, char *file, int line) @@ -282,6 +289,13 @@ } static __inline void +_ng_hook_set_to_inbound(hook_p hook, char * file, int line) +{ + _chkhook(hook, file, line); + _NG_HOOK_SET_TO_INBOUND(hook); +} + +static __inline void _ng_hook_hi_stack(hook_p hook, char * file, int line) { _chkhook(hook, file, line); @@ -302,6 +316,7 @@ #define NG_HOOK_PEER(hook) _ng_hook_peer(hook, _NN_) #define NG_HOOK_FORCE_WRITER(hook) _ng_hook_force_writer(hook, _NN_) #define NG_HOOK_FORCE_QUEUE(hook) _ng_hook_force_queue(hook, _NN_) +#define NG_HOOK_SET_TO_INBOUND(hook) _ng_hook_set_to_inbound(hook, _NN_) #define NG_HOOK_HI_STACK(hook) _ng_hook_hi_stack(hook, _NN_) #else /* NETGRAPH_DEBUG */ /*----------------------------------------------*/ @@ -319,6 +334,7 @@ #define NG_HOOK_PEER(hook) _NG_HOOK_PEER(hook) #define NG_HOOK_FORCE_WRITER(hook) _NG_HOOK_FORCE_WRITER(hook) #define NG_HOOK_FORCE_QUEUE(hook) _NG_HOOK_FORCE_QUEUE(hook) +#define NG_HOOK_SET_TO_INBOUND(hook) _NG_HOOK_SET_TO_INBOUND(hook) #define NG_HOOK_HI_STACK(hook) _NG_HOOK_HI_STACK(hook) #endif /* NETGRAPH_DEBUG */ /*----------------------------------------------*/ ==== //depot/projects/vimage-commit2/src/sys/netgraph/ng_base.c#33 (text+ko) ==== @@ -2213,11 +2213,16 @@ } /* - * If sender or receiver requests queued delivery or stack usage + * If sender or receiver requests queued delivery, or call graph + * loops back from outbound to inbound path, or stack usage * level is dangerous - enqueue message. */ if ((flags & NG_QUEUE) || (hook && (hook->hk_flags & HK_QUEUE))) { queue = 1; + } else if (hook && (hook->hk_flags & HK_TO_INBOUND) /* && + (curthread->td_flags & TDF_NG_OUTBOUND) */) { +printf("ng queuing: td_flags = %X\n", curthread->td_flags); + queue = 1; } else { queue = 0; #ifdef GET_STACK_USAGE ==== //depot/projects/vimage-commit2/src/sys/netgraph/ng_eiface.c#23 (text+ko) ==== @@ -95,6 +95,7 @@ static ng_rcvmsg_t ng_eiface_rcvmsg; static ng_shutdown_t ng_eiface_rmnode; static ng_newhook_t ng_eiface_newhook; +static ng_connect_t ng_eiface_connect; static ng_rcvdata_t ng_eiface_rcvdata; static ng_disconnect_t ng_eiface_disconnect; @@ -107,6 +108,7 @@ .rcvmsg = ng_eiface_rcvmsg, .shutdown = ng_eiface_rmnode, .newhook = ng_eiface_newhook, + .connect = ng_eiface_connect, .rcvdata = ng_eiface_rcvdata, .disconnect = ng_eiface_disconnect, .cmdlist = ng_eiface_cmdlist @@ -421,6 +423,19 @@ } /* + * Mark a hook as leading to inbound path of the network stack, so + * that framework can queue calls to us that arrived from the outbound + * path. + */ +static int +ng_eiface_connect(hook_p hook) +{ + + NG_HOOK_SET_TO_INBOUND(hook); + return (0); +} + +/* * Receive a control message */ static int ==== //depot/projects/vimage-commit2/src/sys/sys/proc.h#18 (text+ko) ==== @@ -319,7 +319,7 @@ #define TDF_BOUNDARY 0x00000400 /* Thread suspended at user boundary */ #define TDF_ASTPENDING 0x00000800 /* Thread has some asynchronous events. */ #define TDF_TIMOFAIL 0x00001000 /* Timeout from sleep after we were awake. */ -#define TDF_UNUSED2000 0x00002000 /* --available-- */ +#define TDF_NG_OUTBOUND 0x00002000 /* Thread called into ng from ntw stack. */ #define TDF_UPIBLOCKED 0x00004000 /* Thread blocked on user PI mutex. */ #define TDF_NEEDSUSPCHK 0x00008000 /* Thread may need to suspend. */ #define TDF_NEEDRESCHED 0x00010000 /* Thread needs to yield. */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200906092305.n59N5TrV002295>