[Click] function to shut down router in kernel mode

Eddie Kohler kohler at cs.ucla.edu
Mon Oct 4 02:44:41 EDT 2004


Erik VandeKieft wrote:
> OK thanks that's a start, but what about for code that isn't inside an
> element? This is going inside an overloaded "new" because I'm doing my own
> memory allocation and I've just run out of memory. If I just throw
> std::bad_alloc, does the kernel thread come down cleanly?

No no no!!  The kernel environment doesn't support exceptions (the relevant 
stack magic isn't there), unfortunately.  You should not throw exceptions in 
your own code; Click is compiled with -fno-exceptions.  Click elements must be 
robust to memory exhaustion -- and some of them even are :) .  You can see 
things like "if (!_q) return errh->error("out of memory!");" in Queue's 
implementation.

Are you sure that you really want to tear down the router on memory exhaustion? 
  That seems like an easy avenue for DoS.

Anyway, there's no way with the current code to tear down the router without a 
Router or Element pointer, but it'd be pretty easy to add one: add a function to 
Master, or call linuxmodule/config.cc's "kill_router()" function [make it 
nonstatic].

Eddie



> 
> --Erik
> 
> On Sun, 3 Oct 2004, Nikitas Liogkas wrote:
> 
> 
>>You are probably looking for void Router::please_stop_driver(). You
>>can just call it from within an Element like this:
>>router()->please_stop_driver();
>>
>>Hope this helps...
>>
>>nikitas
>>
>>On Sun, 3 Oct 2004, Erik VandeKieft wrote:
>>
>>
>>>Hi,
>>>
>>>Is there a function that I can call in kernel mode that will simply shut
>>>the router down (and cleanly bring down the kernel thread)? I see that on
>>>certain errors the code calls panic(), but I don't want to have to reboot.
>>>
>>>Thanks,
>>>--Erik
>>>_______________________________________________
>>>click mailing list
>>>click at amsterdam.lcs.mit.edu
>>>https://amsterdam.lcs.mit.edu/mailman/listinfo/click
>>>
>>
> _______________________________________________
> click mailing list
> click at amsterdam.lcs.mit.edu
> https://amsterdam.lcs.mit.edu/mailman/listinfo/click



More information about the click mailing list