From owner-p4-projects@FreeBSD.ORG Tue Jun 9 23:05:34 2009 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id DCDB91065679; Tue, 9 Jun 2009 23:05:33 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9CC251065675 for ; Tue, 9 Jun 2009 23:05:33 +0000 (UTC) (envelope-from zec@fer.hr) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 81C878FC27 for ; Tue, 9 Jun 2009 23:05:33 +0000 (UTC) (envelope-from zec@fer.hr) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id n59N5Vlv002297 for ; Tue, 9 Jun 2009 23:05:31 GMT (envelope-from zec@fer.hr) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id n59N5TrV002295 for perforce@freebsd.org; Tue, 9 Jun 2009 23:05:29 GMT (envelope-from zec@fer.hr) Date: Tue, 9 Jun 2009 23:05:29 GMT Message-Id: <200906092305.n59N5TrV002295@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to zec@fer.hr using -f From: Marko Zec To: Perforce Change Reviews Cc: Subject: PERFORCE change 163941 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Jun 2009 23:05:34 -0000 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. */