Re: ksh emacs search-history misbehaviour

2021-09-18 Thread ropers
I appreciate not everyone is as verbose as I can be, but your initial
email was very terse.  For example, when you say:

> in emacs search-history mode, abort if ^@ is encountered

is that the desired behaviour or the problem behaviour?

>From testing, it seems like the current behaviour is that it's
aborting, and from reading only your diff, it looks like you want it
not to abort but ignore an accidentally typed U+ character.  But
it also looks like this could relate to another ksh/emacs.c
history-related issue I've previously observed but STILL not offered
up a diff for.

I think if you elaborated a little, that might make your email more
accessible.  Don't assume people know what you know.  The less
work--even thinking--people need to do to see where you're coming from
the better.  Thus, what are your exact steps, etc.?  Also, what
exactly do zsh and bash do?

I tried to test a little to obtain a better understanding of what's
bugging you (and arguably ksh), and I got somewhat inconsistent
results -- with ksh's behaviour depending on whether I'd already typed
something else.  Sometimes I got a "phantom abort" where it looked
like I was back to the regular prompt but actually wasn't.  I even got
ksh to dump core once, but that was oksh on a Linux box, so YMMV.
In short, I'm not sure I'm really doing and seeing what you're seeing.
I suspect if you described things more comprehensively, that might
help not just little old me understand.

Thanks and regards,
Ian

On 18/09/2021, Alexander Hall  wrote:
> Ping. Please don't be discouraged or scared just because it's a diff to
> ksh(1). It really is rather simple.
>
> Noone else ever ran into this ksh command line history search bug?
>
> /Alexander
>
> On September 14, 2021 12:17:22 AM GMT+02:00, Alexander Hall
>  wrote:
>>in emacs search-history mode, abort if ^@ is encountered
>>
>>This has been bugging me for ages, and I finally realized it was me
>>accidentally pressing Ctrl+, rendering ^@ (a.k.a '\0' or NUL)
>>
>>Easily tested with: Ctrl+R Ctrl+ ...
>>
>>Minimal investigation, for reference:
>>  bash: misbehaves in a slightly different manner
>>  zsh:  behaviour matches this fix
>>
>>OK?
>>
>>Index: emacs.c
>>===
>>RCS file: /cvs/src/bin/ksh/emacs.c,v
>>retrieving revision 1.88
>>diff -u -p -r1.88 emacs.c
>>--- emacs.c   27 Jun 2021 15:53:33 -  1.88
>>+++ emacs.c   13 Sep 2021 21:42:37 -
>>@@ -897,7 +897,7 @@ x_search_hist(int c)
>>  if ((c = x_e_getc()) < 0)
>>  return KSTD;
>>  f = kb_find_hist_func(c);
>>- if (c == CTRL('[')) {
>>+ if (c == CTRL('[') || c == CTRL('@')) {
>>  x_e_ungetc(c);
>>  break;
>>  } else if (f == x_search_hist)
>>
>
>



Re: syslogd domain name

2021-09-18 Thread Todd C . Miller
On Fri, 17 Sep 2021 17:30:24 +0200, Alexander Bluhm wrote:

> The LocalDomain in syslogd(8) is not used, remove variable.
> Use RFC 5424 NILVALUE as fallback for LocalHostName.

OK millert@

 - todd



Re: ksh emacs search-history misbehaviour

2021-09-18 Thread Alexander Hall
Ping. Please don't be discouraged or scared just because it's a diff to ksh(1). 
It really is rather simple.

Noone else ever ran into this ksh command line history search bug?

/Alexander

On September 14, 2021 12:17:22 AM GMT+02:00, Alexander Hall 
 wrote:
>in emacs search-history mode, abort if ^@ is encountered
>
>This has been bugging me for ages, and I finally realized it was me
>accidentally pressing Ctrl+, rendering ^@ (a.k.a '\0' or NUL)
>
>Easily tested with: Ctrl+R Ctrl+ ...
>
>Minimal investigation, for reference:
>  bash: misbehaves in a slightly different manner
>  zsh:  behaviour matches this fix
>
>OK?
>
>Index: emacs.c
>===
>RCS file: /cvs/src/bin/ksh/emacs.c,v
>retrieving revision 1.88
>diff -u -p -r1.88 emacs.c
>--- emacs.c27 Jun 2021 15:53:33 -  1.88
>+++ emacs.c13 Sep 2021 21:42:37 -
>@@ -897,7 +897,7 @@ x_search_hist(int c)
>   if ((c = x_e_getc()) < 0)
>   return KSTD;
>   f = kb_find_hist_func(c);
>-  if (c == CTRL('[')) {
>+  if (c == CTRL('[') || c == CTRL('@')) {
>   x_e_ungetc(c);
>   break;
>   } else if (f == x_search_hist)
>



Re: relayd regress tcp performance

2021-09-18 Thread Jan Klemkow
On Thu, Apr 15, 2021 at 08:43:02PM +0200, Alexander Bluhm wrote:
> I found another regression with Jan's TCP diff that sends less ACK
> packets.  relayd run-args-http-slow-consumer.pl fails on i386 due
> to his commit.  This test writes a lot of data from the http server,
> but blocks receive for 2 seconds in the client.  Relayd between
> these machines should handle the delay.  The socket buffer size is
> very small to trigger the situation reliably.
> 
> The current TCP stack does not recover after the delay.  Packets
> are sent very slowly and the regress test runs in a timeout.  When
> I backout the change, the test passes quickly.
> 
> Ususally the test runs on localhost loopback.  There the problem
> is not triggered.  Only my i386 regress setup uses a remote machine.

This issue is caused by another bug in our stack.  The Stack calls
tcp_output(), but does not send an ACK with a window update, after the
consuming process empties the receive buffer in soreceive().

In normal conditions, the every other ACK feature hides this problem.
Thus, with my diff, the 200ms ACK timer is the only mechanism that sends
out ACKs.  But, this is to slow, to empty the stalled buffer fast
enough.

The following diff removes the every 2nd ACK feature again and ensures
that we send out an ACK if soreceive() empties the receive buffer.

We are so close to 7.0, that I would suggest to commit this after the
release.  Thus, we don't risk another last minute regression.

OK?

bye,
Jan

Index: netinet/tcp_input.c
===
RCS file: /cvs/src/sys/netinet/tcp_input.c,v
retrieving revision 1.370
diff -u -p -r1.370 tcp_input.c
--- netinet/tcp_input.c 9 Aug 2021 17:03:08 -   1.370
+++ netinet/tcp_input.c 18 Sep 2021 07:53:45 -
@@ -176,8 +176,7 @@ do { \
struct ifnet *ifp = NULL; \
if (m && (m->m_flags & M_PKTHDR)) \
ifp = if_get(m->m_pkthdr.ph_ifidx); \
-   if (TCP_TIMER_ISARMED(tp, TCPT_DELACK) || \
-   (tcp_ack_on_push && (tiflags) & TH_PUSH) || \
+   if ((tcp_ack_on_push && (tiflags) & TH_PUSH) || \
(ifp && (ifp->if_flags & IFF_LOOPBACK))) \
tp->t_flags |= TF_ACKNOW; \
else \
Index: netinet/tcp_usrreq.c
===
RCS file: /cvs/src/sys/netinet/tcp_usrreq.c,v
retrieving revision 1.181
diff -u -p -r1.181 tcp_usrreq.c
--- netinet/tcp_usrreq.c30 Apr 2021 13:52:48 -  1.181
+++ netinet/tcp_usrreq.c18 Sep 2021 07:53:45 -
@@ -329,8 +329,15 @@ tcp_usrreq(struct socket *so, int req, s
 * template for a listening socket and hence the kernel
 * will panic.
 */
-   if ((so->so_state & (SS_ISCONNECTED|SS_ISCONNECTING)) != 0)
+   if ((so->so_state & (SS_ISCONNECTED|SS_ISCONNECTING)) != 0) {
+   /*
+* If soreceive() empty the receive buffer, we have to
+* send a window update.
+*/
+   if (so->so_rcv.sb_cc == 0)
+   tp->t_flags |= TF_ACKNOW;
(void) tcp_output(tp);
+   }
break;
 
/*



pf NAT source port translation of MAP-E Customer Edge (RFC 7597)

2021-09-18 Thread Toru Mano

Hi tech,

MAP-E (RFC 7597) transports IPv4 packets across an IPv6 network using
IP encapsulation. MAP-E uses a single IPv4 address for multiple
customers. To distinguish customers at Border Relay, each Customer
Edge must use an exclusive port set. This patch provides an option to
specify the port set used in MAP-E Customer Edge.

I made this patch by referring to the following FreeBSD patch with the
same intention (Though internal codes are different, and thus the
patches are also different).
https://reviews.freebsd.org/D29468

(This patch is also available at
https://github.com/toru-mano/src/compare/master...toru-mano:mape)

Regards,
Toru

diff --git regress/sbin/pfctl/Makefile regress/sbin/pfctl/Makefile
index 7813ad3d7a3..d6436681e27 100644
--- regress/sbin/pfctl/Makefile
+++ regress/sbin/pfctl/Makefile
@@ -17,10 +17,10 @@ PFTESTS=1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 
19 20 21 22 23 24 25 26 27

 PFTESTS+=28 29 30 31 32 34 35 36 38 39 40 41 44 46 47 48 49 50
 PFTESTS+=52 53 54 55 56 57 60 61 65 66 67 68 69 70 71 72 73
 PFTESTS+=74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 
94 95 96

-PFTESTS+=97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
+PFTESTS+=97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 114
 PFFAIL=1 2 3 4 5 6 7 8 11 12 13 14 15 16 17 19 20 23 25 27
 PFFAIL+=30 37 38 39 40 41 42 43 47 48 49 50 51 52 53 54 55 56 57 58 59 
60 61 62

-PFFAIL+=63 64 65 66 67
+PFFAIL+=63 64 65 66 67 68
 PFSIMPLE=1 2
 PFSETUP=1 4
 PFLOAD=1 2 3 4 5 7 8 9 10 11 12 13 14 15 16 17 18 19 20 23 24 25 26 27 
28 29

diff --git regress/sbin/pfctl/pf114.in regress/sbin/pfctl/pf114.in
new file mode 100644
index 000..d218c215681
--- /dev/null
+++ regress/sbin/pfctl/pf114.in
@@ -0,0 +1 @@
+pass out on lo0 nat-to (lo0) map-e-portset 1/2/3
diff --git regress/sbin/pfctl/pf114.ok regress/sbin/pfctl/pf114.ok
new file mode 100644
index 000..5fb041c
--- /dev/null
+++ regress/sbin/pfctl/pf114.ok
@@ -0,0 +1 @@
+pass out on lo0 all flags S/SA nat-to (lo0) round-robin map-e-portset 1/2/3
diff --git regress/sbin/pfctl/pfail68.in regress/sbin/pfctl/pfail68.in
new file mode 100644
index 000..d8ac607f05f
--- /dev/null
+++ regress/sbin/pfctl/pfail68.in
@@ -0,0 +1,9 @@
+match out on lo0 nat-to (lo0) map-e-portset 1/2/3 map-e-portset 4/5/6
+match out on lo0 nat-to (lo0) map-e-portset 0/2/3
+match out on lo0 nat-to (lo0) map-e-portset 16/2/3
+match out on lo0 nat-to (lo0) map-e-portset 8/10/3
+match out on lo0 nat-to (lo0) map-e-portset 1/2/-1
+match out on lo0 nat-to (lo0) map-e-portset 1/10/1024
+match out on lo0 rdr-to (lo0) map-e-portset 1/2/3
+match out on lo0 nat-to (lo0) static-port map-e-portset 1/2/3
+match out on lo0 nat-to (lo0) port 1000:2000 map-e-portset 1/2/3
diff --git regress/sbin/pfctl/pfail68.ok regress/sbin/pfctl/pfail68.ok
new file mode 100644
index 000..314cdcc5dde
--- /dev/null
+++ regress/sbin/pfctl/pfail68.ok
@@ -0,0 +1,15 @@
+stdin:1: map-e-portset cannot be redefined
+stdin:2: MAP-E PSID offset must be 1-15: 0
+stdin:3: MAP-E PSID offset must be 1-15: 16
+stdin:4: invalid MAP-E PSID length: 10
+stdin:5: invalid MAP-E PSID: -1
+stdin:6: invalid MAP-E PSID: 1024
+stdin:7: the 'map-e-portset' option is only valid with nat rules
+stdin:7: skipping rule due to errors
+stdin:7: rule expands to no valid combination
+stdin:8: the 'map-e-portset' option can't be used with 'static-port'
+stdin:8: skipping rule due to errors
+stdin:8: rule expands to no valid combination
+stdin:9: the 'map-e-portset' option can't be used when specifying a 
port range

+stdin:9: skipping rule due to errors
+stdin:9: rule expands to no valid combination
diff --git sbin/pfctl/parse.y sbin/pfctl/parse.y
index a10bc6f315c..894e59eea0c 100644
--- sbin/pfctl/parse.y
+++ sbin/pfctl/parse.y
@@ -213,6 +213,7 @@ struct pool_opts {
 int             type;
 int             staticport;
 struct pf_poolhashkey    *key;
+    struct pf_mape_port     mape;

 } pool_opts;

@@ -478,6 +479,7 @@ int    parseport(char *, struct range *r, int);
 %token    SYNPROXY FINGERPRINTS NOSYNC DEBUG SKIP HOSTID
 %token    ANTISPOOF FOR INCLUDE MATCHES
 %token    BITMASK RANDOM SOURCEHASH ROUNDROBIN LEASTSTATES STATICPORT 
PROBABILITY

+%token    MAPEPORTSET
 %token    WEIGHT BANDWIDTH FLOWS QUANTUM
 %token    QUEUE PRIORITY QLIMIT RTABLE RDOMAIN MINIMUM BURST PARENT
 %token    LOAD RULESET_OPTIMIZATION RTABLE RDOMAIN PRIO ONCE DEFAULT DELAY
@@ -2622,7 +2624,7 @@ xhost        : not host            {
         $$->tail = $$;
     }
     ;
-
+
 optweight    : WEIGHT NUMBER            {
         if ($2 < 1 || $2 > USHRT_MAX) {
             yyerror("weight out of range");
@@ -3525,7 +3527,7 @@ portstar    : numberstring            {
     }
     ;

-redirspec    : host optweight        {
+redirspec    : host optweight        {
         if ($2 > 0) {
             struct node_host    *n;
             for (n = $1; n != NULL; n = n->next)
@@ -3692,6 +3694,29 @@ pool_