9front - general discussion about 9front
 help / color / mirror / Atom feed
From: hiro <23hiro@gmail.com>
To: 9front@9front.org
Subject: Re: [9front] [PITCH] ip/null
Date: Mon, 11 Dec 2023 20:05:29 +0100	[thread overview]
Message-ID: <CAFSF3XNwgZa+h2=Ab=JRyihpKHsVCKr+nnHsk-u3krdVhsRMYw@mail.gmail.com> (raw)
In-Reply-To: <d806068d-f846-4880-8e01-bbe30f492720@posixcafe.org>

it would be good if it wouldn't need to get all the way to userland
before being dropped.

On 12/11/23, Jacob Moody <moody@posixcafe.org> wrote:
> This as obsoleted by cinap's aux/dial(1).
> It functionally works the same here except you would
> need an explicit direction to /dev/null.
>
> ie.
>
> aux/dial
> 'ipmux!ifc=my.external.ip;dst=192.168.0.0&255.255.0.0|10.0.0.0&255.0.0.0' >
> /dev/null
>
> On 12/11/23 12:54, unobe@cpan.org wrote:
>> FWIW, I haven't seen anyone else comment on this, but I like it.
>>
>> Quoth Jacob Moody <moody@mail.posixcafe.org>:
>>> As I play around more with 9front as my router, I found myself reaching
>>> for some
>>> kind of 'firewall'. I find that we already have a pretty good interface
>>> in the kernel
>>> in the form of ipmux. But there isn't too many ways of making use of it
>>> as is. I hacked up
>>> something quick to just drop packets matching a filter on to the floor.
>>> If others find it
>>> useful I can make up a man page and present again with a bit more
>>> polish.
>>>
>>> Some examples:
>>> # Drop inbound private range
>>> ip/null
>>> 'ifc=my.external.ip;dst=192.168.0.0&255.255.0.0|10.0.0.0&255.0.0.0'
>>>
>>> # google verboden
>>> ip/null 'ifc=my.internal.ip;dst=8.8.8.8;src=192.168.0.0&255.255.0.0'
>>>
>>> thanks,
>>> moody
>>>
>>> --- /dev/null
>>> +++ b//sys/src/cmd/ip/null.c
>>> @@ -1,0 +1,36 @@
>>> +#include <u.h>
>>> +#include <libc.h>
>>> +
>>> +void
>>> +usage(void)
>>> +{
>>> +	fprint(2, "usage: %s filter\n", argv0);
>>> +	exits("usage");
>>> +}
>>> +
>>> +void
>>> +main(int argc, char **argv)
>>> +{
>>> +	char buf[64 * 1024];
>>> +	int fd;
>>> +
>>> +	ARGBEGIN{
>>> +	default:
>>> +		usage();
>>> +		break;
>>> +	}ARGEND
>>> +	if(argc < 1)
>>> +		usage();
>>> +
>>> +	fd = dial(smprint("ipmux!%s", argv[0]), nil, nil, nil);
>>> +	if(fd < 0)
>>> +		sysfatal("dial: %r");
>>> +
>>> +	for(;;)
>>> +		switch(read(fd, buf, sizeof buf)){
>>> +		case -1:
>>> +			sysfatal("read: %r");
>>> +		case 0:
>>> +			return;
>>> +		}
>>> +}
>>
>
>

  reply	other threads:[~2023-12-11 19:06 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-16  3:42 Jacob Moody
2023-12-11 18:54 ` unobe
2023-12-11 19:00   ` Jacob Moody
2023-12-11 19:05     ` hiro [this message]
2023-12-11 19:11       ` Jacob Moody
2023-12-11 19:17         ` hiro
2023-12-11 19:22           ` Jacob Moody
2023-12-11 19:32             ` hiro
2023-12-11 19:45     ` unobe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAFSF3XNwgZa+h2=Ab=JRyihpKHsVCKr+nnHsk-u3krdVhsRMYw@mail.gmail.com' \
    --to=23hiro@gmail.com \
    --cc=9front@9front.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).