From owner-freebsd-net Fri Nov 22 2:25:11 2002 Delivered-To: freebsd-net@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D244F37B401 for ; Fri, 22 Nov 2002 02:25:07 -0800 (PST) Received: from albatross.wise.edt.ericsson.se (albatross-ext.wise.edt.ericsson.se [193.180.251.49]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9BFEE43EA3 for ; Fri, 22 Nov 2002 02:25:05 -0800 (PST) (envelope-from mattias.pettersson@era.ericsson.se) Received: from esealnt613.al.sw.ericsson.se (esealnt613.al.sw.ericsson.se [153.88.254.72]) by albatross.wise.edt.ericsson.se (8.12.1/8.12.1/WIREfire-1.4) with ESMTP id gAMAOtKV009878; Fri, 22 Nov 2002 11:24:55 +0100 (MET) Received: from era.ericsson.se (Idiotgisslan.ki.sw.ericsson.se [147.214.181.237]) by esealnt613.al.sw.ericsson.se with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2655.55) id WWLJ4JS1; Fri, 22 Nov 2002 11:24:54 +0100 Message-ID: <3DDE045F.5CC8F5B5@era.ericsson.se> Date: Fri, 22 Nov 2002 11:18:07 +0100 X-Sybari-Trust: e8f45b93 ca231590 698a2c29 00000138 From: Mattias Pettersson Organization: Ericsson Research X-Mailer: Mozilla 4.79 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 To: snap-users@kame.net Cc: freebsd-net@freebsd.org Subject: Re: (KAME-snap 7197) Interrupt levels and concurrency References: <3DDD0E1B.80C8C4AA@it.uc3m.es> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org Hi, Giving it a try: Juan Francisco Rodriguez Hervella wrote: > > Hello (again :) > > I'm doing my best, but I'm in a mess trying to understand > the interrup levels and if I should take it into account > to implement what I want to implement :) > > As I'm working with KAME source code, I will CC this question. > (KAME people always help me a lot :) > > I have the following situation: I've got an array, which > is filled in using received packets, but it can also be filled in > using the function "getaddrinfo()". Finally, this array > is searched inside ip_output() function. > > So I was thinking of implementing the interaction between "getaddrinfo" > and this kernel-array using "sysctl" interface, but I was wondering > if I need to low the interrup level to fill in this array inside the > sysctl_function(), because it could happen that at the same time > a new packet arrived at and it can try to access the same structure. Yes, I think you should protect that piece of code with "spl(net)... " inside sysctl, in case ip_input is pre-empting it. Doing that you can be sure that no other code running at "net" level will mess with the array. > > I've implemented some other code with sysctls calls and I've never > worried about the interrups levels, but now I've got a doubt... > does "sysctl" takes into account the likehood of concurrent system calls > ? > I hope so.... > > Returning to my implementation, Would I have to worry about the case > when "getaddrinfo" is calling to sysctl to add a new entry and then the > function ip_output() begins to search the share structure also ? > No. ip_output() I think runs at spl(net) too, so as long as sysctl is running at net it should work fine. In addition, user space does not really have any priority over kernel. > I can see that my array can be accesed from (at least) the following > points: > > 1. User layer (getaddrinfo) > 2. IP layer (ip_input, ip_output) > > I was thinking of calling directly to the sysctl_function() inside > ip_input() and also inside ip_output(). I hope there's no problem with > this. Not sure.Subject: Re: (KAME-snap 7197) Interrupt levels and concurrency Date: Fri, 22 Nov 2002 09:57:57 +0100 From: Mattias Pettersson Organization: Ericsson Research To: jrh@it.uc3m.es References: 1 Hi, I send this to you privately, because I don't want to embarass myself on the lists if I'm saying something stupid... ;) Juan Francisco Rodriguez Hervella wrote: > > Hello (again :) > > I'm doing my best, but I'm in a mess trying to understand > the interrup levels and if I should take it into account > to implement what I want to implement :) > > As I'm working with KAME source code, I will CC this question. > (KAME people always help me a lot :) > > I have the following situation: I've got an array, which > is filled in using received packets, but it can also be filled in > using the function "getaddrinfo()". Finally, this array > is searched inside ip_output() function. > > So I was thinking of implementing the interaction between "getaddrinfo" > and this kernel-array using "sysctl" interface, but I was wondering > if I need to low the interrup level to fill in this array inside the > sysctl_function(), because it could happen that at the same time > a new packet arrived at and it can try to access the same structure. Yes, I think you should protect that piece of code with "spl(net)... " inside sysctl, in case ip_input is pre-empting it. Doing that you can be sure that no other code running at "net" level will mess with the array. > > I've implemented some other code with sysctls calls and I've never > worried about the interrups levels, but now I've got a doubt... > does "sysctl" takes into account the likehood of concurrent system calls > ? > I hope so.... > > Returning to my implementation, Would I have to worry about the case > when "getaddrinfo" is calling to sysctl to add a new entry and then the > function ip_output() begins to search the share structure also ? > No. ip_output() I think runs at spl(net) too, so as long as sysctl is running at net it should work fine. In addition, user space does not really have any priority over kernel. > I can see that my array can be accesed from (at least) the following > points: > > 1. User layer (getaddrinfo) > 2. IP layer (ip_input, ip_output) > > I was thinking of calling directly to the sysctl_function() inside > ip_input() and also inside ip_output(). I hope there's no problem with > this. Not sure. I once tried to reuse in6_control() in the kernel to achieve something like an "ifconfig", but KAME didn't like that. Hope it helps. /Mattias > > Could you suggest me anything ? You have a lot of experience > with these topics, and any guideline or explanation that you give > me will be very very thanksfully thanked (sorry for my awful English :) > > Thanks! > > -- > JFRH. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message