Re: Remove manpage references to sparc

2019-11-04 Thread Jason McIntyre
On Sun, Nov 03, 2019 at 03:37:43PM +, Joe Davis wrote:
> sparc support hasn't existed for 6 releases, the following diff removes
> some remaining references to sun4c and sun4e machines in the manpages.
> 
> Cheers,
> Joe
> 

fixed, thanks.
jmc

> Index: hme.4
> ===
> RCS file: /cvs/src/share/man/man4/hme.4,v
> retrieving revision 1.15
> diff -u -p -r1.15 hme.4
> --- hme.4 27 Mar 2015 21:15:46 -  1.15
> +++ hme.4 3 Nov 2019 15:34:25 -
> @@ -98,8 +98,3 @@ support for the
>  .Nm
>  first appeared in
>  .Ox 2.4 .
> -.Sh CAVEATS
> -The
> -.Nm
> -SBus cards will not function in a sun4c or sun4e class machine,
> -due to SBus limitations on these systems.
> Index: options.4
> ===
> RCS file: /cvs/src/share/man/man4/options.4,v
> retrieving revision 1.266
> diff -u -p -r1.266 options.4
> --- options.4 6 Sep 2019 21:30:32 -   1.266
> +++ options.4 3 Nov 2019 15:34:25 -
> @@ -265,13 +265,6 @@ retaining the safety of synchronous meta
>  Soft updates must be enabled on a per-filesystem basis.
>  See
>  .Xr mount 8 .
> -.Pp
> -Processors with a small kernel address space, such as the sun4 and sun4c, do
> -not have enough kernel memory to support soft updates.
> -Attempts to use this option with these CPUs will cause a kernel hang or panic
> -after a short period of use as the kernel will quickly run out of memory.
> -This is not related to the amount of physical memory present in the
> -machine \(em it is a limitation of the CPU architecture itself.
>  .It Cd option FIFO
>  Adds support for
>  .At V
> 



Re: sysupgrade(8) and http_proxy

2019-11-04 Thread trondd
Steffen Nurpmeso  wrote:

> trondd wrote in <49f29107642e86c17283b0582a9f09f4.squir...@mail.kagu-tsu\
> chi.com>:
>  |On Sun, November 3, 2019 12:02 pm, trondd wrote:
>  |> On Sun, November 3, 2019 6:27 am, Florian Obser wrote:
>  |>> On Sun, Nov 03, 2019 at 12:21:59PM +0100, Antoine Jacoutot wrote:
>  |>>> On Sun, Nov 03, 2019 at 12:16:56PM +0100, Florian Obser wrote:
>  ...
>  |I've tested the diff and it works as expected in my environment.  I don't
>  |need a username and password for proxy access but it populates the
>  |rc.firsttime file fine.
>  |
>  |The quote() function is actually pretty simple.
>  |
>  |quote() (
>  |# Since this is a subshell we won't pollute the calling namespace.
>  |for _a; do
>  |# alias string to Q, does escaping and quoting
>  |alias Q=$_a;
>  |# set variable back to value of alias
>  |_a=$(alias Q);
>  |# print variable, chopping off alias definition
>  |#   no newline, don't substitute the escape sequences
>  |#   we made above
>  |print -rn -- " ${_a#Q=}"
>  |done | sed '1s/ //'
>  |echo
>  |)
> 
> I felt a bit undecided from your first mail on, maybe also because
> of your mailer, but wanted to post the all-compatible all-shell
> quote of and from Robert Elz here.
> 
>   #@ Round trip quote strings in POSIX shell.  E.g.,
>   #@set -- x 'a \ b' "foo'" "\\'b\\a\\r\\" Aä
>   #@printf "%s: <%s><%s><%s><%s><%s>\n" "$#" "${1}" "${2}" "${3}" "$4" 
> "$5"
>   #@saved_parameters=`quote_rndtrip "$@"`
>   #@eval "set -- $saved_parameters"
>   #@printf "%s: <%s><%s><%s><%s><%s>\n" "$#" "${1}" "${2}" "${3}" "$4" 
> "$5"
>   #
>   # 2017 Robert Elz (kre).
> 
> ...
> 
>   # Though slower use a subshell version instead of properly restoring $IFS
>   # and flags, as elder shells may not be able to properly restore flags via
>   # "set +o" as later standardized in POSIX, and it seems overkill to handle
>   # all possible forms of output "set +o" may or may not actually generate.
>   quote__rndtrip() (
>  case "$1" in
>  *\'*) ;;
>  *) printf "'%s'" "$1"; return 0;;
>  esac
>  a="$1" s= e=
>  while case "$a" in
> \'*)  a=${a#?}; s="${s}'";;
> *\')  a=${a%?}; e="${e}'";;
> '')   printf "${s}${e}"; exit 0;;
> *) false;;
> esac
>  do
> continue
>  done
>  IFS=\'
>  set -f
>  set -- $a
>  r="${1}"
>   shift
>  for a
>  do
> r="${r}'\\''${a}"
>  done
>  printf "${s}'%s'${e}" "${r}"
>  exit 0
>   )
> 
>   quote_rndtrip() (
>  j=
>  for i
>  do
> [ -n "$j" ] && printf ' '
> j=' '
> quote__rndtrip "$i"
>  done
>   )
> 
>   quote_string() (
>  j=
>  for i
>  do
> [ -n "$j" ] && printf '\\ '
> j=' '
> quote__rndtrip "$i"
>  done
>   )
> 
> 
>  |$ export "test=fancy ' stuff #and not a comment"
>  |$ ./quote.ksh
>  |$ cat test.out
>  |
>  |export 'http_proxy=fancy '\'' stuff #and not a comment'
>  |
>  |$ export "test=even
>  |> this works #"
>  |$ ./quote.ksh
>  |$ cat test.out
>  |
>  |export 'http_proxy=even
>  |this works #'
> 
> Of course, if in install.sub there is already your quote function,
> that surely is preferred.
> 
> Good night,
> 
> --steffen
> |
> |Der Kragenbaer,The moon bear,
> |der holt sich munter   he cheerfully and one by one
> |einen nach dem anderen runter  wa.ks himself off
> |(By Robert Gernhardt)

To clarify, it's not my quote function.  It's been in install.sub since
2010 [0] and was used when http_proxy was added there [1].  I figured it
was a good idea so pulled it in for sysupgrade as well.

[0] 
http://cvsweb.openbsd.org/src/distrib/miniroot/install.sub?rev=1.628&content-type=text/x-cvsweb-markup
[1] 
http://cvsweb.openbsd.org/src/distrib/miniroot/install.sub?rev=1.1058&content-type=text/x-cvsweb-markup

Tim.



use designators for array initialiser in src/sys/netinet/in.h CTL_IPPROTO_NAMES

2019-11-04 Thread David Gwynne
this makes it harder to mess up the assignment of a protocol to the
right slot in the CTL_IPPROTO_NAMES initialiser. it also shrinks the
code a lot, and i think it makes what the array index means a lot more
explicit.

this gets used in sysctl(8), which still works as expected after
this change. we use designators for init in other places, so i don't
see this one as being a problem, even on older compilers.

ok?

Index: in.h
===
RCS file: /cvs/src/sys/netinet/in.h,v
retrieving revision 1.137
diff -u -p -r1.137 in.h
--- in.h4 Nov 2019 23:52:28 -   1.137
+++ in.h5 Nov 2019 01:16:56 -
@@ -386,265 +386,23 @@ struct ip_mreq {
 #defineIPPROTO_MAXID   (IPPROTO_DIVERT + 1)/* don't list to 
IPPROTO_MAX */
 
 #defineCTL_IPPROTO_NAMES { \
-   { "ip", CTLTYPE_NODE }, \
-   { "icmp", CTLTYPE_NODE }, \
-   { "igmp", CTLTYPE_NODE }, \
-   { "ggp", CTLTYPE_NODE }, \
-   { "ipip", CTLTYPE_NODE }, \
-   { 0, 0 }, \
-   { "tcp", CTLTYPE_NODE }, \
-   { 0, 0 }, \
-   { "egp", CTLTYPE_NODE }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { "pup", CTLTYPE_NODE }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { "udp", CTLTYPE_NODE }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { "gre", CTLTYPE_NODE }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { "esp", CTLTYPE_NODE }, \
-   { "ah", CTLTYPE_NODE }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { "etherip", CTLTYPE_NODE }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { "ipcomp", CTLTYPE_NODE }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { "carp", CTLTYPE_NODE }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 }, \
-   { 0, 0 

Re: sysupgrade(8) and http_proxy

2019-11-04 Thread Steffen Nurpmeso
trondd wrote in <49f29107642e86c17283b0582a9f09f4.squir...@mail.kagu-tsu\
chi.com>:
 |On Sun, November 3, 2019 12:02 pm, trondd wrote:
 |> On Sun, November 3, 2019 6:27 am, Florian Obser wrote:
 |>> On Sun, Nov 03, 2019 at 12:21:59PM +0100, Antoine Jacoutot wrote:
 |>>> On Sun, Nov 03, 2019 at 12:16:56PM +0100, Florian Obser wrote:
 ...
 |I've tested the diff and it works as expected in my environment.  I don't
 |need a username and password for proxy access but it populates the
 |rc.firsttime file fine.
 |
 |The quote() function is actually pretty simple.
 |
 |quote() (
 |# Since this is a subshell we won't pollute the calling namespace.
 |for _a; do
 |# alias string to Q, does escaping and quoting
 |alias Q=$_a;
 |# set variable back to value of alias
 |_a=$(alias Q);
 |# print variable, chopping off alias definition
 |#   no newline, don't substitute the escape sequences
 |#   we made above
 |print -rn -- " ${_a#Q=}"
 |done | sed '1s/ //'
 |echo
 |)

I felt a bit undecided from your first mail on, maybe also because
of your mailer, but wanted to post the all-compatible all-shell
quote of and from Robert Elz here.

  #@ Round trip quote strings in POSIX shell.  E.g.,
  #@set -- x 'a \ b' "foo'" "\\'b\\a\\r\\" Aä
  #@printf "%s: <%s><%s><%s><%s><%s>\n" "$#" "${1}" "${2}" "${3}" "$4" "$5"
  #@saved_parameters=`quote_rndtrip "$@"`
  #@eval "set -- $saved_parameters"
  #@printf "%s: <%s><%s><%s><%s><%s>\n" "$#" "${1}" "${2}" "${3}" "$4" "$5"
  #
  # 2017 Robert Elz (kre).

...

  # Though slower use a subshell version instead of properly restoring $IFS
  # and flags, as elder shells may not be able to properly restore flags via
  # "set +o" as later standardized in POSIX, and it seems overkill to handle
  # all possible forms of output "set +o" may or may not actually generate.
  quote__rndtrip() (
 case "$1" in
 *\'*) ;;
 *) printf "'%s'" "$1"; return 0;;
 esac
 a="$1" s= e=
 while case "$a" in
\'*)  a=${a#?}; s="${s}'";;
*\')  a=${a%?}; e="${e}'";;
'')   printf "${s}${e}"; exit 0;;
*) false;;
esac
 do
continue
 done
 IFS=\'
 set -f
 set -- $a
 r="${1}"
  shift
 for a
 do
r="${r}'\\''${a}"
 done
 printf "${s}'%s'${e}" "${r}"
 exit 0
  )

  quote_rndtrip() (
 j=
 for i
 do
[ -n "$j" ] && printf ' '
j=' '
quote__rndtrip "$i"
 done
  )

  quote_string() (
 j=
 for i
 do
[ -n "$j" ] && printf '\\ '
j=' '
quote__rndtrip "$i"
 done
  )


 |$ export "test=fancy ' stuff #and not a comment"
 |$ ./quote.ksh
 |$ cat test.out
 |
 |export 'http_proxy=fancy '\'' stuff #and not a comment'
 |
 |$ export "test=even
 |> this works #"
 |$ ./quote.ksh
 |$ cat test.out
 |
 |export 'http_proxy=even
 |this works #'

Of course, if in install.sub there is already your quote function,
that surely is preferred.

Good night,

--steffen
|
|Der Kragenbaer,The moon bear,
|der holt sich munter   he cheerfully and one by one
|einen nach dem anderen runter  wa.ks himself off
|(By Robert Gernhardt)



use tasks and a task_list to manage if_detachhooks

2019-11-04 Thread David Gwynne
hook_establish can fail, but drivers are inconsistent about checking for
that. apparently there's also a requirement that detach hooks are
run in opposite order to the one they were established in, but that
is also applied inconsistently by drivers.

this replaces if_detachhooks with a task_list, and has users of it
allocate an set a struct task to put on it. this means the users of it
allocate the task up front as part of their per port or softc structure,
so adding the task to the if_detachhooks list cannot fail. to enforce
the required ordering, ive added wrappers around the list operations.

ive had this as a long standing itch to scratch, but i was forced into
action after looking at a report by markus@ about the order of these
hook establishment/disestablishments in carp. if you reparent a carp
interface, you've established detach hooks on multiple interfaces, but
if you need to roll back you can lose one of them. this reorders the ops
so you only add the detach hook after you've been put on the new
interface, and because adding the detach hook is reliable there's no
rollback or unwinding to implement.

i would love some testing. ive only kicked a few of the tyres on this
one.

ok?

if people are ok with this, i'll go through and do the same for the link
state and address change hooks.

Index: net/if.c
===
RCS file: /cvs/src/sys/net/if.c,v
retrieving revision 1.588
diff -u -p -r1.588 if.c
--- net/if.c21 Aug 2019 15:32:18 -  1.588
+++ net/if.c4 Nov 2019 22:51:52 -
@@ -632,9 +623,7 @@ if_attach_common(struct ifnet *ifp)
ifp->if_linkstatehooks = malloc(sizeof(*ifp->if_linkstatehooks),
M_TEMP, M_WAITOK);
TAILQ_INIT(ifp->if_linkstatehooks);
-   ifp->if_detachhooks = malloc(sizeof(*ifp->if_detachhooks),
-   M_TEMP, M_WAITOK);
-   TAILQ_INIT(ifp->if_detachhooks);
+   TAILQ_INIT(&ifp->if_detachhooks);
 
if (ifp->if_rtrequest == NULL)
ifp->if_rtrequest = if_rtrequest_dummy;
@@ -1046,17 +1035,36 @@ if_netisr(void *unused)
 void
 if_deactivate(struct ifnet *ifp)
 {
-   NET_LOCK();
+   struct task *t, *nt;
+
/*
 * Call detach hooks from head to tail.  To make sure detach
 * hooks are executed in the reverse order they were added, all
 * the hooks have to be added to the head!
 */
-   dohooks(ifp->if_detachhooks, HOOK_REMOVE | HOOK_FREE);
 
+   NET_LOCK();
+   TAILQ_FOREACH_SAFE(t, &ifp->if_detachhooks, t_entry, nt)
+   (*t->t_func)(t->t_arg);
+
+   KASSERT(TAILQ_EMPTY(&ifp->if_detachhooks));
NET_UNLOCK();
 }
 
+void
+if_detachhook_add(struct ifnet *ifp, struct task *t)
+{
+   NET_ASSERT_LOCKED();
+   TAILQ_INSERT_HEAD(&ifp->if_detachhooks, t, t_entry);
+}
+
+void
+if_detachhook_del(struct ifnet *ifp, struct task *t)
+{
+   NET_ASSERT_LOCKED();
+   TAILQ_REMOVE(&ifp->if_detachhooks, t, t_entry);
+}
+
 /*
  * Detach an interface from everything in the kernel.  Also deallocate
  * private resources.
@@ -1132,7 +1140,6 @@ if_detach(struct ifnet *ifp)
 
free(ifp->if_addrhooks, M_TEMP, sizeof(*ifp->if_addrhooks));
free(ifp->if_linkstatehooks, M_TEMP, sizeof(*ifp->if_linkstatehooks));
-   free(ifp->if_detachhooks, M_TEMP, sizeof(*ifp->if_detachhooks));
 
for (i = 0; (dp = domains[i]) != NULL; i++) {
if (dp->dom_ifdetach && ifp->if_afdata[dp->dom_family])
Index: net/if_aggr.c
===
RCS file: /cvs/src/sys/net/if_aggr.c,v
retrieving revision 1.19
diff -u -p -r1.19 if_aggr.c
--- net/if_aggr.c   5 Aug 2019 10:42:51 -   1.19
+++ net/if_aggr.c   4 Nov 2019 22:51:52 -
@@ -336,7 +336,7 @@ struct aggr_port {
struct rtentry *);
 
void*p_lcookie;
-   void*p_dcookie;
+   struct task  p_dtask;
 
struct aggr_softc   *p_aggr;
TAILQ_ENTRY(aggr_port)   p_entry;
@@ -1138,8 +1138,9 @@ aggr_add_port(struct aggr_softc *sc, con
 
p->p_lcookie = hook_establish(ifp0->if_linkstatehooks, 1,
aggr_p_linkch, p);
-   p->p_dcookie = hook_establish(ifp0->if_detachhooks, 0,
-   aggr_p_detach, p);
+
+   task_set(&p->p_dtask, aggr_p_detach, p);
+   if_detachhook_add(ifp0, &p->p_dtask);
 
task_set(&p->p_rxm_task, aggr_rx, p);
mq_init(&p->p_rxm_mq, 3, IPL_NET);
@@ -1427,7 +1428,7 @@ aggr_p_dtor(struct aggr_softc *sc, struc
ifp->if_xname, op, ifp0->if_xname);
}
 
-   hook_disestablish(ifp0->if_detachhooks, p->p_dcookie);
+   if_detachhook_del(ifp0, &p->p_dtask);
hook_disestablish(ifp0->if_linkstatehooks, p->p_lcookie);
 
if_put(ifp0);
Index: net/if_bpe.c
===
RCS file: /cvs/src/sys/net/if_bpe.c,v
retrieving revision 

Re: sysupgrade(8) and http_proxy

2019-11-04 Thread trondd
On Sun, November 3, 2019 12:02 pm, trondd wrote:
> On Sun, November 3, 2019 6:27 am, Florian Obser wrote:
>> On Sun, Nov 03, 2019 at 12:21:59PM +0100, Antoine Jacoutot wrote:
>>> On Sun, Nov 03, 2019 at 12:16:56PM +0100, Florian Obser wrote:
>>> > I like it, if someone who is fluent in ksh line noise could please
>>> > verify and commit, that would be awesome, thanks.
>>>
>>> Why not let the installer handle this? It already has code for it.
>>> sysupgrade ony needs to create the proper auto_upgrade.conf containing
>>> the
>>> answer to the proxy question.
>>
>> Right, that is better.
>>
>
> Unless I'm missing something, the installer only asks for a proxy when you
> select 'http' for the sets for a network install which sysupgrade is
> designed to not do.
>
> This would mean changing the installer to ask for a proxy regardless of
> install method.  Which could make sense since the execution of tools in
> rc.firsttime requires internet access regardless of set installation
> method.
>
> I don't know that much of a change is desired, though.
>
> Tim.
>

I've tested the diff and it works as expected in my environment.  I don't
need a username and password for proxy access but it populates the
rc.firsttime file fine.

The quote() function is actually pretty simple.

quote() (
# Since this is a subshell we won't pollute the calling namespace.
for _a; do
# alias string to Q, does escaping and quoting
alias Q=$_a;
# set variable back to value of alias
_a=$(alias Q);
# print variable, chopping off alias definition
#   no newline, don't substitute the escape sequences
#   we made above
print -rn -- " ${_a#Q=}"
done | sed '1s/ //'
echo
)

$ export "test=fancy ' stuff #and not a comment"
$ ./quote.ksh
$ cat test.out

export 'http_proxy=fancy '\'' stuff #and not a comment'

$ export "test=even
> this works #"
$ ./quote.ksh
$ cat test.out

export 'http_proxy=even
this works #'


Tim.


>>>
>>>
>>> >
>>> > On Fri, Nov 01, 2019 at 09:37:04PM -0400, trondd wrote:
>>> > > Anthony Coulter  wrote:
>>> > >
>>> > > > Hello @tech,
>>> > > >
>>> > > > When I manually upgrade OpenBSD using bsd.rd, I have to set
>>> http_proxy
>>> > > > to fetch the file sets. When I reboot after installing, fw_update
>>> > > > succeeds because theinstall script was clever enough to export
>>> > > > http_proxy in /etc/rc.firsttime.
>>> > > >
>>> > > > Unfortunately sysupgrade(8) does not remember that http_proxy was
>>> set
>>> > > > when it fetched the file sets, and so when I run sysupgrade I
>>> have
>>> to
>>> > > > either wait for fw_update to manually time out on first reboot,
>>> or
>>> kill
>>> > > > it manually with ^C.
>>> > > >
>>> > > > Adding the line:
>>> > > >
>>> > > > [ ${http_proxy} ] && echo "export http_proxy=${http_proxy}"
>>> >>/etc/rc.firsttime
>>> > > >
>>> > > > to a spot near the bottom of /usr/sbin/sysupgrade fixes my
>>> fw_update
>>> > > > problem, at least until the upgrade restores all of my files to
>>> their
>>> > > > stock defaults. Is this something we could integrate into the
>>> official
>>> > > > repository?
>>> > > >
>>> > > > Thanks and regards,
>>> > > > Anthony Coulter
>>> > >
>>> > > Here it is in patch form in case there is interest.  This also
>>> pulls
>>> in the
>>> > > quote function from install.sub to make sure a proxy username or
>>> password is
>>> > > quoted properly.  I haven't tested this since I could only use it
>>> at
>>> work.
>>> > >
>>> > > Tim.
>>> > >
>>> > >
>>> > > Index: sysupgrade.sh
>>> > > ===
>>> > > RCS file: /cvs/src/usr.sbin/sysupgrade/sysupgrade.sh,v
>>> > > retrieving revision 1.29
>>> > > diff -u -p -r1.29 sysupgrade.sh
>>> > > --- sysupgrade.sh   26 Oct 2019 04:04:20 -  1.29
>>> > > +++ sysupgrade.sh   2 Nov 2019 00:39:05 -
>>> > > @@ -73,6 +73,16 @@ rmel() {
>>> > > echo -n "$_c"
>>> > >  }
>>> > >
>>> > > +# Prints the supplied parameters properly escaped for future
>>> sh/ksh
>>> parsing.
>>> > > +# Quotes are added if needed, so you should not do that yourself.
>>> > > +quote() (
>>> > > +   # Since this is a subshell we won't pollute the calling
>>> namespace.
>>> > > +   for _a; do
>>> > > +   alias Q=$_a; _a=$(alias Q); print -rn -- " ${_a#Q=}"
>>> > > +   done | sed '1s/ //'
>>> > > +   echo
>>> > > +)
>>> > > +
>>> > >  RELEASE=false
>>> > >  SNAP=false
>>> > >  FORCE=false
>>> > > @@ -199,6 +209,9 @@ if ! ${KEEP}; then
>>> > >  rm -f /home/_sysupgrade/{${CLEAN}}
>>> > >  __EOT
>>> > >  fi
>>> > > +
>>> > > +[[ -n $http_proxy ]] &&
>>> > > +   quote export "http_proxy=$http_proxy" >>/etc/rc.firsttime
>>> > >
>>> > >  install -F -m 700 bsd.rd /bsd.upgrade
>>> > >  sync
>>> > >
>>> >
>>> > --
>>> > I'm not entirely sure you are real.
>>> >
>>>
>>> --
>>> Antoine
>>>
>>
>> --
>> I'm not

Re: ospfd: type p2p

2019-11-04 Thread Remi Locherer
On Mon, Nov 04, 2019 at 02:01:57PM +0200, Kapetanakis Giannis wrote:
> On 25/10/2019 13:57, Remi Locherer wrote:
> > Hi tech@,
> >
> > earlier this year I sent a diff that allowed to change an interface
> > from broadcast to point-to-point.
> >
> > https://marc.info/?l=openbsd-tech&m=156132923203704&w=2
> >
> > It turned out that this was not sufficient. It made the adjacency
> > come up in p2p mode (no selection of DR or BDR) but didn't set a valid
> > next hop for routes learned over this p2p link. Actually the next hop was
> > 0.0.0.0 which was never installed into the routing table.
> >
> > This is because for P2P interfaces the neighbor address is not taken from
> > the received hello but from the "destination" parameter configured on the
> > interface. Since this is not set on a broadcast interface the address is
> > 0.0.0.0.
> >
> > My new diff changes this. Now also for P2P links the IP address of the
> > neighbor is taken from the hello packets (src address). This on it's own
> > would make it simpler to interfere with the routing from remote. One could
> > send unicast ospf hello messages and potentially disrupt the routing setup.
> > I believe I mitigated this with an additional check I committed in August:
> > only hello messages sent to the multicast address are now processed.
> >
> > The config looks like this:
> >
> > area 0.0.0.0 {
> > interface em0 {
> > type p2p
> > }
> > }
> >
> > It would be nice to get test reports for this new feature (check the fib
> > and routing table!) and also test reports with real p2p2 interfaces (gif
> > or gre).
> >
> > Of course OKs are also welcome. ;-)
> >
> > Remi
> 
> 
> Hi,
> 
> From first test seems to work :)

Thank you for testing!

> 
> looking forward test it for IPv6 as well

Sure, I plan to also do this this for ospf6d.



rwlock(9): xr rwsleep(9)

2019-11-04 Thread Anton Lindqvist
ok?

Index: rwlock.9
===
RCS file: /cvs/src/share/man/man9/rwlock.9,v
retrieving revision 1.24
diff -u -p -r1.24 rwlock.9
--- rwlock.925 Feb 2019 22:03:56 -  1.24
+++ rwlock.94 Nov 2019 14:25:19 -
@@ -238,6 +238,7 @@ Lock is not locked.
 .Sh SEE ALSO
 .Xr witness 4 ,
 .Xr mutex 9 ,
+.Xr rwsleep 9 ,
 .Xr spl 9
 .Sh HISTORY
 The



Re: ix(4) need support for X553

2019-11-04 Thread Joerg Goltermann

Hello,

thank you so much, I did some tests with my X553 and the system survived
all of my tests. Running tcpbench and unplugging the cables several times,
ifconfig down & up.


I think, the performance looks good too:
cpu0 at mainbus0: apid 4 (boot processor)
cpu0: Intel(R) Atom(TM) CPU C3558 @ 2.20GHz, 2200.41 MHz, 06-5f-01
...
ix0 at pci6 dev 0 function 0 "Intel X553 SGMII" rev 0x11: msi, address 
00:90:0b:5f:80:98
ix1 at pci6 dev 0 function 1 "Intel X553 SGMII" rev 0x11: msi, address 
00:90:0b:5f:80:99
ix2 at pci7 dev 0 function 0 "Intel X553 SGMII" rev 0x11: msi, address 
00:90:0b:5f:80:9a
ix3 at pci7 dev 0 function 1 "Intel X553 SGMII" rev 0x11: msi, address 
00:90:0b:5f:80:9b


running a back to back (2 rdomains) tcpbench with pf disabled and
mtu 1500 results in about 880 Mbit/s and using mtu 9000 in 990 Mbit/s

I run the tcpbench all the weekend and did not see any problems.

Nice work! I would really love to see the update in GENERIC.

 - Joerg


On 31.10.2019 16:00, sven falempin wrote:

On Thu, Oct 31, 2019 at 9:49 AM sven falempin 
wrote:




On Thu, Oct 31, 2019 at 9:17 AM Stuart Henderson 
wrote:


On 2019/10/31 08:25, sven falempin wrote:

Thank you, the ./dev/pci/pcidevs_data.h,  pcidevs.h are completly

removed from this

The pcidevs update is no longer needed since pcidevs r1.1889.


I may have time to test it against 6.6, see if it is still working

since 6.4 (where it was

tested, also a cross test revealed
that plugin'/unplugging SFP maybe non functionnal)


I can test an already-wprking fibre ix for new problems at some point,
but I don't
think I'll have a fibre X553.



ppb7 at pci0 dev 22 function 0 "Intel C3000 PCIE" rev 0x11
"Intel X553 SFP+" rev 0x11 at pci8 dev 0 function 0 not configured
"Intel X553 SFP+" rev 0x11 at pci8 dev 0 function 1 not configured
ppb8 at pci0 dev 23 function 0 "Intel C3000 PCIE" rev 0x11
"Intel X553 SFP+" rev 0x11 at pci9 dev 0 function 0 not configured
"Intel X553 SFP+" rev 0x11 at pci9 dev 0 function 1 not configured

When I look at them , some more involved people was talking about 10gb in
OpenBSD .

Isn't there some limitations currently or can we expect the X553  to
perform at 10Gb ?




Hey looks like my diff still works

OpenBSD 6.6-stable (GENERIC.MP) #21: Thu Oct 31 10:53:41 EDT 2019
ix0 at pci8 dev 0 function 0 "Intel X553 SFP+" rev 0x11: msi, address
00:30:18:0b:4a:81
ix1 at pci8 dev 0 function 1 "Intel X553 SFP+" rev 0x11: msi, address
00:30:18:0b:4a:82
ix2 at pci9 dev 0 function 0 "Intel X553 SFP+" rev 0x11: msi, address
00:30:18:0b:4a:83
ix3 at pci9 dev 0 function 1 "Intel X553 SFP+" rev 0x11: msi, address
00:30:18:0b:4a:84

# ifconfig ix
ix0: flags=8802 mtu 1500
 lladdr 00:30:18:0b:4a:81
 index 3 priority 0 llprio 3
 media: Ethernet autoselect
 status: no carrier
ix1: flags=8802 mtu 1500
 lladdr 00:30:18:0b:4a:82
 index 4 priority 0 llprio 3
 media: Ethernet autoselect (10GbaseSR full-duplex)
 status: active
ix2: flags=8802 mtu 1500
 lladdr 00:30:18:0b:4a:83
 index 5 priority 0 llprio 3
 media: Ethernet autoselect
 status: no carrier
ix3: flags=8802 mtu 1500
 lladdr 00:30:18:0b:4a:84
 index 6 priority 0 llprio 3
 media: Ethernet autoselect (10GbaseSR full-duplex)
 status: active

# ifconfig ix1 rdomain 1 10.0.0.1
# ifconfig ix3 rdomain 3 10.0.0.3
# ping -V 3 10.0.0.1
PING 10.0.0.1 (10.0.0.1): 56 data bytes
64 bytes from 10.0.0.1: icmp_seq=0 ttl=255 time=0.573 ms
64 bytes from 10.0.0.1: icmp_seq=1 ttl=255 time=0.246 ms

# route -T 1 exec iperf -c 10.0.0.3

Client connecting to 10.0.0.3, TCP port 5001
TCP window size: 17.0 KByte (default)

[  3] local 10.0.0.1 port 29912 connected with 10.0.0.3 port 5001
[ ID] Interval   Transfer Bandwidth
[  3]  0.0-10.0 sec   871 MBytes   731 Mbits/sec

If anyone want to help run it faster, you re welcome.





Re: iwm: support new umac scan API

2019-11-04 Thread Stefan Sperling
On Mon, Nov 04, 2019 at 09:06:03AM -0700, Tracey Emery wrote:
> On Mon, Nov 04, 2019 at 04:56:14PM +0100, Stefan Sperling wrote:
> > If you want to test -34 you can copy the -34 firmware file on top of
> > the -22 file. (Keep a backup!)
> > 
> > Alternatively, you could change the filename the driver will look for.
> > The lines in if_iwm.c which would need to be changed contain the
> > expected firmware file name, for instance:
> > 
> > sc->sc_fwname = "iwm-8265-22";
> > 
> > So just replace -22 with -34 and rebuild the kernel.
> 
> Yup, definitely missed something obvious. Running stable on -34 as well.
 
Great, thank you! Please keep running it and let me know if you come
across anything wonky :-)



Re: iwm: support new umac scan API

2019-11-04 Thread Tracey Emery
On Mon, Nov 04, 2019 at 04:56:14PM +0100, Stefan Sperling wrote:
> If you want to test -34 you can copy the -34 firmware file on top of
> the -22 file. (Keep a backup!)
> 
> Alternatively, you could change the filename the driver will look for.
> The lines in if_iwm.c which would need to be changed contain the
> expected firmware file name, for instance:
> 
>   sc->sc_fwname = "iwm-8265-22";
> 
> So just replace -22 with -34 and rebuild the kernel.

Yup, definitely missed something obvious. Running stable on -34 as well.

-- 

Tracey Emery



Re: iwm: support new umac scan API

2019-11-04 Thread Stefan Sperling
On Mon, Nov 04, 2019 at 08:31:07AM -0700, Tracey Emery wrote:
> Both diffs work fine here. However, it appears I'm still only loading
> the -22 firmware:
> 
> iwm0: hw rev 0x230, fw ver 22.391740.0
> 
> Am I missing something obvious to get it to load the -34 firmware, or do
> the two work in conjunction? I tried moving the -22 firmware out of the
> way, but that caused a lot of havoc.

If you want to test -34 you can copy the -34 firmware file on top of
the -22 file. (Keep a backup!)

Alternatively, you could change the filename the driver will look for.
The lines in if_iwm.c which would need to be changed contain the
expected firmware file name, for instance:

sc->sc_fwname = "iwm-8265-22";

So just replace -22 with -34 and rebuild the kernel.



Re: iwm: support new umac scan API

2019-11-04 Thread Tracey Emery
Both diffs work fine here. However, it appears I'm still only loading
the -22 firmware:

iwm0: hw rev 0x230, fw ver 22.391740.0

Am I missing something obvious to get it to load the -34 firmware, or do
the two work in conjunction? I tried moving the -22 firmware out of the
way, but that caused a lot of havoc.

Tracey

On Mon, Nov 04, 2019 at 02:25:59PM +0100, Stefan Sperling wrote:
> This diff adds support for new iwm firmare's umac scan API.
> It is required to make scanning work on -34 firmware.
> Combined with the 'new ADD_STA' diff I just sent out, this is the last
> change we need to get -34 firmware working.
> 
> This adds a couple of lines under #ifdef notyet for ax200 devices (which
> are the post-9k generation of devices). I kept these while porting the
> necessary changes from Linux, because we will eventually need them.
> 
> I really don't like that huge union of structs but that is how Linux
> solved the backwards compat issue. Unless Intel starts providing newer
> firmware images for old devices (unlikely) keeping track of which API
> version is needed with which fimware image is only going to get more
> difficult over time. So I'd prefer our approach to remain close enough to
> Linux to allow code for newer devices to be ported without too much effort.
> 
> ok?
>  
> diff 0181db2e1507c7a303c9d89a8410f8181993d536 
> 7ccc2a384b9e6c567f74851744d872e72c7d91bc
> blob - 73727efa2ad5d72670c6c2129ee76f4e77797652
> blob + 0199163cc7f36c58992a881dd498b30ff1febc38
> --- sys/dev/pci/if_iwm.c
> +++ sys/dev/pci/if_iwm.c
> @@ -546,7 +546,9 @@ iwm_firmware_store_section(struct iwm_softc *sc, enum 
>   return 0;
>  }
>  
> -#define IWM_DEFAULT_SCAN_CHANNELS 40
> +#define IWM_DEFAULT_SCAN_CHANNELS40
> +/* Newer firmware might support more channels. Raise this value if needed. */
> +#define IWM_MAX_SCAN_CHANNELS52 /* as of 8265-34 firmware 
> image */
>  
>  struct iwm_tlv_calib_data {
>   uint32_t ucode_type;
> @@ -837,6 +839,10 @@ iwm_read_firmware(struct iwm_softc *sc, enum iwm_ucode
>   }
>   sc->sc_capa_n_scan_channels =
> le32toh(*(uint32_t *)tlv_data);
> + if (sc->sc_capa_n_scan_channels > 
> IWM_MAX_SCAN_CHANNELS) {
> + err = ERANGE;
> + goto parse_out;
> + }
>   break;
>  
>   case IWM_UCODE_TLV_FW_VERSION:
> @@ -4939,6 +4945,24 @@ iwm_umac_scan_fill_channels(struct iwm_softc *sc,
>  }
>  
>  int
> +iwm_fill_probe_req_v1(struct iwm_softc *sc, struct iwm_scan_probe_req_v1 
> *preq1)
> +{
> + struct iwm_scan_probe_req preq2;
> + int err, i;
> +
> + err = iwm_fill_probe_req(sc, &preq2);
> + if (err)
> + return err;
> +
> + preq1->mac_header = preq2.mac_header;
> + for (i = 0; i < nitems(preq1->band_data); i++)
> + preq1->band_data[i] = preq2.band_data[i];
> + preq1->common_data = preq2.common_data;
> + memcpy(preq1->buf, preq2.buf, sizeof(preq1->buf));
> + return 0;
> +}
> +
> +int
>  iwm_fill_probe_req(struct iwm_softc *sc, struct iwm_scan_probe_req *preq)
>  {
>   struct ieee80211com *ic = &sc->sc_ic;
> @@ -5042,12 +5066,13 @@ iwm_lmac_scan(struct iwm_softc *sc, int bgscan)
>   .flags = 0,
>   };
>   struct iwm_scan_req_lmac *req;
> + struct iwm_scan_probe_req_v1 *preq;
>   size_t req_len;
>   int err, async = bgscan;
>  
>   req_len = sizeof(struct iwm_scan_req_lmac) +
>   (sizeof(struct iwm_scan_channel_cfg_lmac) *
> - sc->sc_capa_n_scan_channels) + sizeof(struct iwm_scan_probe_req);
> + sc->sc_capa_n_scan_channels) + sizeof(struct iwm_scan_probe_req_v1);
>   if (req_len > IWM_MAX_CMD_PAYLOAD_SIZE)
>   return ENOMEM;
>   req = malloc(req_len, M_DEVBUF,
> @@ -5120,10 +5145,10 @@ iwm_lmac_scan(struct iwm_softc *sc, int bgscan)
>   (struct iwm_scan_channel_cfg_lmac *)req->data,
>   ic->ic_des_esslen != 0, bgscan);
>  
> - err = iwm_fill_probe_req(sc,
> - (struct iwm_scan_probe_req *)(req->data +
> - (sizeof(struct iwm_scan_channel_cfg_lmac) *
> - sc->sc_capa_n_scan_channels)));
> + preq = (struct iwm_scan_probe_req_v1 *)(req->data +
> + (sizeof(struct iwm_scan_channel_cfg_lmac) *
> + sc->sc_capa_n_scan_channels));
> + err = iwm_fill_probe_req_v1(sc, preq);
>   if (err) {
>   free(req, M_DEVBUF, req_len);
>   return err;
> @@ -5184,9 +5209,7 @@ iwm_config_umac_scan(struct iwm_softc *sc)
>   IEEE80211_ADDR_COPY(scan_config->mac_addr, sc->sc_ic.ic_myaddr);
>  
>   scan_config->bcast_sta_id = IWM_AUX_STA_ID;
> - scan_config->channel_flags = IWM_CHANNEL_FLAG_EBS |
> - IWM_CHANNEL_FLAG_ACCURATE_EBS | IWM_CHANNEL_FLAG_EBS_ADD |
> - IWM_CHANNEL_FLAG_PRE_SCAN_PASSIVE2ACTIVE;
> + scan

iwm: support new umac scan API

2019-11-04 Thread Stefan Sperling
This diff adds support for new iwm firmare's umac scan API.
It is required to make scanning work on -34 firmware.
Combined with the 'new ADD_STA' diff I just sent out, this is the last
change we need to get -34 firmware working.

This adds a couple of lines under #ifdef notyet for ax200 devices (which
are the post-9k generation of devices). I kept these while porting the
necessary changes from Linux, because we will eventually need them.

I really don't like that huge union of structs but that is how Linux
solved the backwards compat issue. Unless Intel starts providing newer
firmware images for old devices (unlikely) keeping track of which API
version is needed with which fimware image is only going to get more
difficult over time. So I'd prefer our approach to remain close enough to
Linux to allow code for newer devices to be ported without too much effort.

ok?
 
diff 0181db2e1507c7a303c9d89a8410f8181993d536 
7ccc2a384b9e6c567f74851744d872e72c7d91bc
blob - 73727efa2ad5d72670c6c2129ee76f4e77797652
blob + 0199163cc7f36c58992a881dd498b30ff1febc38
--- sys/dev/pci/if_iwm.c
+++ sys/dev/pci/if_iwm.c
@@ -546,7 +546,9 @@ iwm_firmware_store_section(struct iwm_softc *sc, enum 
return 0;
 }
 
-#define IWM_DEFAULT_SCAN_CHANNELS 40
+#define IWM_DEFAULT_SCAN_CHANNELS  40
+/* Newer firmware might support more channels. Raise this value if needed. */
+#define IWM_MAX_SCAN_CHANNELS  52 /* as of 8265-34 firmware image */
 
 struct iwm_tlv_calib_data {
uint32_t ucode_type;
@@ -837,6 +839,10 @@ iwm_read_firmware(struct iwm_softc *sc, enum iwm_ucode
}
sc->sc_capa_n_scan_channels =
  le32toh(*(uint32_t *)tlv_data);
+   if (sc->sc_capa_n_scan_channels > 
IWM_MAX_SCAN_CHANNELS) {
+   err = ERANGE;
+   goto parse_out;
+   }
break;
 
case IWM_UCODE_TLV_FW_VERSION:
@@ -4939,6 +4945,24 @@ iwm_umac_scan_fill_channels(struct iwm_softc *sc,
 }
 
 int
+iwm_fill_probe_req_v1(struct iwm_softc *sc, struct iwm_scan_probe_req_v1 
*preq1)
+{
+   struct iwm_scan_probe_req preq2;
+   int err, i;
+
+   err = iwm_fill_probe_req(sc, &preq2);
+   if (err)
+   return err;
+
+   preq1->mac_header = preq2.mac_header;
+   for (i = 0; i < nitems(preq1->band_data); i++)
+   preq1->band_data[i] = preq2.band_data[i];
+   preq1->common_data = preq2.common_data;
+   memcpy(preq1->buf, preq2.buf, sizeof(preq1->buf));
+   return 0;
+}
+
+int
 iwm_fill_probe_req(struct iwm_softc *sc, struct iwm_scan_probe_req *preq)
 {
struct ieee80211com *ic = &sc->sc_ic;
@@ -5042,12 +5066,13 @@ iwm_lmac_scan(struct iwm_softc *sc, int bgscan)
.flags = 0,
};
struct iwm_scan_req_lmac *req;
+   struct iwm_scan_probe_req_v1 *preq;
size_t req_len;
int err, async = bgscan;
 
req_len = sizeof(struct iwm_scan_req_lmac) +
(sizeof(struct iwm_scan_channel_cfg_lmac) *
-   sc->sc_capa_n_scan_channels) + sizeof(struct iwm_scan_probe_req);
+   sc->sc_capa_n_scan_channels) + sizeof(struct iwm_scan_probe_req_v1);
if (req_len > IWM_MAX_CMD_PAYLOAD_SIZE)
return ENOMEM;
req = malloc(req_len, M_DEVBUF,
@@ -5120,10 +5145,10 @@ iwm_lmac_scan(struct iwm_softc *sc, int bgscan)
(struct iwm_scan_channel_cfg_lmac *)req->data,
ic->ic_des_esslen != 0, bgscan);
 
-   err = iwm_fill_probe_req(sc,
-   (struct iwm_scan_probe_req *)(req->data +
-   (sizeof(struct iwm_scan_channel_cfg_lmac) *
-   sc->sc_capa_n_scan_channels)));
+   preq = (struct iwm_scan_probe_req_v1 *)(req->data +
+   (sizeof(struct iwm_scan_channel_cfg_lmac) *
+   sc->sc_capa_n_scan_channels));
+   err = iwm_fill_probe_req_v1(sc, preq);
if (err) {
free(req, M_DEVBUF, req_len);
return err;
@@ -5184,9 +5209,7 @@ iwm_config_umac_scan(struct iwm_softc *sc)
IEEE80211_ADDR_COPY(scan_config->mac_addr, sc->sc_ic.ic_myaddr);
 
scan_config->bcast_sta_id = IWM_AUX_STA_ID;
-   scan_config->channel_flags = IWM_CHANNEL_FLAG_EBS |
-   IWM_CHANNEL_FLAG_ACCURATE_EBS | IWM_CHANNEL_FLAG_EBS_ADD |
-   IWM_CHANNEL_FLAG_PRE_SCAN_PASSIVE2ACTIVE;
+   scan_config->channel_flags = 0;
 
for (c = &ic->ic_channels[1], nchan = 0;
c <= &ic->ic_channels[IEEE80211_CHAN_MAX] &&
@@ -5218,6 +5241,72 @@ iwm_config_umac_scan(struct iwm_softc *sc)
 }
 
 int
+iwm_umac_scan_size(struct iwm_softc *sc)
+{
+   int base_size = IWM_SCAN_REQ_UMAC_SIZE_V1;
+   int tail_size;
+
+   if (isset(sc->sc_ucode_api, IWM_UCODE_TLV_API_ADAPTIVE_DWELL_V2))
+   base_size = IWM_SCAN_REQ_UMAC_SIZE_V8;
+   else if (isset(sc->sc_ucode_api, I

iwm: support new ADD_STA command

2019-11-04 Thread Stefan Sperling
Add support for the new ADD_STA command API. Required for -34 firmware.

The significant changes are that the purpose of each STA in the firmware
table is now identified by an 'STA type' flag, and that the Rx block ack
window size is now specified in the command. The layout is backwards
compatible, so we can copy less data into the command's data buffer to 
keep our current firmware images happy.

Please update your tree before applying this diff. I just committed
a bunch of fixes to the driver which this diff is built on top of.

ok?
 
diff ad75f5225873df6d70b1e074b9130e23531b6d7d 
0181db2e1507c7a303c9d89a8410f8181993d536
blob - e03955bfd1ac8861d79049fc422828d1f264f777
blob + 73727efa2ad5d72670c6c2129ee76f4e77797652
--- sys/dev/pci/if_iwm.c
+++ sys/dev/pci/if_iwm.c
@@ -328,7 +328,7 @@ int iwm_ampdu_rx_start(struct ieee80211com *, struct i
 void   iwm_ampdu_rx_stop(struct ieee80211com *, struct ieee80211_node *,
uint8_t);
 void   iwm_sta_rx_agg(struct iwm_softc *, struct ieee80211_node *, uint8_t,
-   uint16_t, int);
+   uint16_t, uint16_t, int);
 #ifdef notyet
 intiwm_ampdu_tx_start(struct ieee80211com *, struct ieee80211_node *,
uint8_t);
@@ -2575,13 +2575,14 @@ iwm_setup_ht_rates(struct iwm_softc *sc)
 
 void
 iwm_sta_rx_agg(struct iwm_softc *sc, struct ieee80211_node *ni, uint8_t tid,
-uint16_t ssn, int start)
+uint16_t ssn, uint16_t winsize, int start)
 {
struct ieee80211com *ic = &sc->sc_ic;
-   struct iwm_add_sta_cmd_v7 cmd;
+   struct iwm_add_sta_cmd cmd;
struct iwm_node *in = (void *)ni;
int err, s;
uint32_t status;
+   size_t cmdsize;
 
if (start && sc->sc_rx_ba_sessions >= IWM_MAX_RX_BA_SESSIONS) {
ieee80211_addba_req_refuse(ic, ni, tid);
@@ -2598,6 +2599,7 @@ iwm_sta_rx_agg(struct iwm_softc *sc, struct ieee80211_
if (start) {
cmd.add_immediate_ba_tid = (uint8_t)tid;
cmd.add_immediate_ba_ssn = ssn;
+   cmd.rx_ba_window = winsize;
} else {
cmd.remove_immediate_ba_tid = (uint8_t)tid;
}
@@ -2605,7 +2607,11 @@ iwm_sta_rx_agg(struct iwm_softc *sc, struct ieee80211_
IWM_STA_MODIFY_REMOVE_BA_TID;
 
status = IWM_ADD_STA_SUCCESS;
-   err = iwm_send_cmd_pdu_status(sc, IWM_ADD_STA, sizeof(cmd), &cmd,
+   if (isset(sc->sc_ucode_api, IWM_UCODE_TLV_API_STA_TYPE))
+   cmdsize = sizeof(cmd);
+   else
+   cmdsize = sizeof(struct iwm_add_sta_cmd_v7);
+   err = iwm_send_cmd_pdu_status(sc, IWM_ADD_STA, cmdsize, &cmd,
&status);
 
s = splnet();
@@ -2673,9 +2679,10 @@ iwm_ba_task(void *arg)
}

if (sc->ba_start)
-   iwm_sta_rx_agg(sc, ni, sc->ba_tid, sc->ba_ssn, 1);
+   iwm_sta_rx_agg(sc, ni, sc->ba_tid, sc->ba_ssn,
+   sc->ba_winsize, 1);
else
-   iwm_sta_rx_agg(sc, ni, sc->ba_tid, 0, 0);
+   iwm_sta_rx_agg(sc, ni, sc->ba_tid, 0, 0, 0);
 
refcnt_rele_wake(&sc->task_refs);
splx(s);
@@ -2698,6 +2705,7 @@ iwm_ampdu_rx_start(struct ieee80211com *ic, struct iee
sc->ba_start = 1;
sc->ba_tid = tid;
sc->ba_ssn = htole16(ba->ba_winstart);
+   sc->ba_winsize = htole16(ba->ba_winsize);
iwm_add_task(sc, systq, &sc->ba_task);
 
return EBUSY;
@@ -4703,9 +4711,10 @@ iwm_disable_beacon_filter(struct iwm_softc *sc)
 int
 iwm_add_sta_cmd(struct iwm_softc *sc, struct iwm_node *in, int update)
 {
-   struct iwm_add_sta_cmd_v7 add_sta_cmd;
+   struct iwm_add_sta_cmd add_sta_cmd;
int err;
uint32_t status;
+   size_t cmdsize;
struct ieee80211com *ic = &sc->sc_ic;
 
if (!update && (sc->sc_flags & IWM_FLAG_STA_ACTIVE))
@@ -4714,6 +4723,8 @@ iwm_add_sta_cmd(struct iwm_softc *sc, struct iwm_node 
memset(&add_sta_cmd, 0, sizeof(add_sta_cmd));
 
add_sta_cmd.sta_id = IWM_STATION_ID;
+   if (isset(sc->sc_ucode_api, IWM_UCODE_TLV_API_STA_TYPE))
+   add_sta_cmd.station_type = IWM_STA_LINK;
add_sta_cmd.mac_id_n_color
= htole32(IWM_FW_CMD_ID_AND_COLOR(in->in_id, in->in_color));
if (!update) {
@@ -4764,7 +4775,11 @@ iwm_add_sta_cmd(struct iwm_softc *sc, struct iwm_node 
}
 
status = IWM_ADD_STA_SUCCESS;
-   err = iwm_send_cmd_pdu_status(sc, IWM_ADD_STA, sizeof(add_sta_cmd),
+   if (isset(sc->sc_ucode_api, IWM_UCODE_TLV_API_STA_TYPE))
+   cmdsize = sizeof(add_sta_cmd);
+   else
+   cmdsize = sizeof(struct iwm_add_sta_cmd_v7);
+   err = iwm_send_cmd_pdu_status(sc, IWM_ADD_STA, cmdsize,
&add_sta_cmd, &status);
if (!err && (status & IWM_ADD_STA_STATUS_MASK) != IWM_ADD_STA_SUCCESS)
err = EIO;
@@ -4775,9 +4790,10 @@ iwm_add_sta_cmd(struct iwm_softc *sc, struct iwm_node 
 int
 iwm_add_aux_sta(struct iwm_softc *sc)
 {
-   struct iwm_

Re: ospfd: type p2p

2019-11-04 Thread Kapetanakis Giannis
On 25/10/2019 13:57, Remi Locherer wrote:
> Hi tech@,
>
> earlier this year I sent a diff that allowed to change an interface
> from broadcast to point-to-point.
>
> https://marc.info/?l=openbsd-tech&m=156132923203704&w=2
>
> It turned out that this was not sufficient. It made the adjacency
> come up in p2p mode (no selection of DR or BDR) but didn't set a valid
> next hop for routes learned over this p2p link. Actually the next hop was
> 0.0.0.0 which was never installed into the routing table.
>
> This is because for P2P interfaces the neighbor address is not taken from
> the received hello but from the "destination" parameter configured on the
> interface. Since this is not set on a broadcast interface the address is
> 0.0.0.0.
>
> My new diff changes this. Now also for P2P links the IP address of the
> neighbor is taken from the hello packets (src address). This on it's own
> would make it simpler to interfere with the routing from remote. One could
> send unicast ospf hello messages and potentially disrupt the routing setup.
> I believe I mitigated this with an additional check I committed in August:
> only hello messages sent to the multicast address are now processed.
>
> The config looks like this:
>
> area 0.0.0.0 {
>   interface em0 {
>   type p2p
>   }
> }
>
> It would be nice to get test reports for this new feature (check the fib
> and routing table!) and also test reports with real p2p2 interfaces (gif
> or gre).
>
> Of course OKs are also welcome. ;-)
>
> Remi


Hi,

>From first test seems to work :)

looking forward test it for IPv6 as well

thanks

Giannis

>
>
>
> Index: hello.c
> ===
> RCS file: /cvs/src/usr.sbin/ospfd/hello.c,v
> retrieving revision 1.24
> diff -u -p -r1.24 hello.c
> --- hello.c   12 Aug 2019 20:21:58 -  1.24
> +++ hello.c   21 Sep 2019 22:06:17 -
> @@ -189,14 +189,13 @@ recv_hello(struct iface *iface, struct i
>   nbr->dr.s_addr = hello.d_rtr;
>   nbr->bdr.s_addr = hello.bd_rtr;
>   nbr->priority = hello.rtr_priority;
> - /* XXX neighbor address shouldn't be stored on virtual links */
> - nbr->addr.s_addr = src.s_addr;
> + nbr_update_addr(nbr->peerid, src);
>   }
>  
>   if (nbr->addr.s_addr != src.s_addr) {
>   log_warnx("%s: neighbor ID %s changed its IP address",
>   __func__, inet_ntoa(nbr->id));
> - nbr->addr.s_addr = src.s_addr;
> + nbr_update_addr(nbr->peerid, src);
>   }
>  
>   nbr->options = hello.opts;
> Index: lsupdate.c
> ===
> RCS file: /cvs/src/usr.sbin/ospfd/lsupdate.c,v
> retrieving revision 1.46
> diff -u -p -r1.46 lsupdate.c
> --- lsupdate.c15 Jul 2019 18:26:39 -  1.46
> +++ lsupdate.c15 Aug 2019 21:10:13 -
> @@ -470,7 +470,7 @@ ls_retrans_timer(int fd, short event, vo
>   /* ls_retrans_list_free retriggers the timer */
>   return;
>   } else if (nbr->iface->type == IF_TYPE_POINTOPOINT)
> - memcpy(&addr, &nbr->iface->dst, sizeof(addr));
> + memcpy(&addr, &nbr->addr, sizeof(addr));
>   else
>   inet_aton(AllDRouters, &addr);
>   } else
> Index: neighbor.c
> ===
> RCS file: /cvs/src/usr.sbin/ospfd/neighbor.c,v
> retrieving revision 1.48
> diff -u -p -r1.48 neighbor.c
> --- neighbor.c9 Feb 2018 02:14:03 -   1.48
> +++ neighbor.c21 Sep 2019 15:28:43 -
> @@ -312,6 +312,7 @@ nbr_new(u_int32_t nbr_id, struct iface *
>   bzero(&rn, sizeof(rn));
>   rn.id.s_addr = nbr->id.s_addr;
>   rn.area_id.s_addr = nbr->iface->area->id.s_addr;
> + rn.addr.s_addr = nbr->addr.s_addr;
>   rn.ifindex = nbr->iface->ifindex;
>   rn.state = nbr->state;
>   rn.self = self;
> @@ -347,6 +348,23 @@ nbr_del(struct nbr *nbr)
>   LIST_REMOVE(nbr, hash);
>  
>   free(nbr);
> +}
> +
> +int
> +nbr_update_addr(u_int32_t peerid, struct in_addr addr) {
> +
> + struct nbr  *nbr = NULL;
> +
> + nbr = nbr_find_peerid(peerid);
> + if (nbr == NULL)
> + return (1);
> +
> + /* XXX neighbor address shouldn't be stored on virtual links */
> + nbr->addr.s_addr = addr.s_addr;
> + ospfe_imsg_compose_rde(IMSG_NEIGHBOR_ADDR, peerid, 0, &addr,
> + sizeof(addr));
> +
> + return (0);
>  }
>  
>  struct nbr *
> Index: ospfd.c
> ===
> RCS file: /cvs/src/usr.sbin/ospfd/ospfd.c,v
> retrieving revision 1.108
> diff -u -p -r1.108 ospfd.c
> --- ospfd.c   16 May 2019 05:49:22 -  1.108
> +++ ospfd.c   23 Jun 2019 21:06:44 -
> @@ -911,6 +911,22 @@ merge_interfaces(struct area *a, struct 
>  

Re: [PATCH] remove sysctl net.mpls.maxloop_inkernel

2019-11-04 Thread thomas
(adding claudio as the most recent contributor)

As per https://marc.info/?l=openbsd-misc&m=157191651123338&w=2 this is
no longer used and can be removed.

Before:
$ sysctl -a | grep mpls
net.mpls.ttl=255
net.mpls.maxloop_inkernel=16
net.mpls.mapttl_ip=1
net.mpls.mapttl_ip6=0

After:
$ sysctl -a | grep mpls
net.mpls.ttl=255
net.mpls.mapttl_ip=1
net.mpls.mapttl_ip6=0

--
typedef struct me_s {
  char name[]  = { "Thomas Habets" };
  char email[] = { "tho...@habets.se" };
  char kernel[]= { "Linux" };
  char *pgpKey[]   = { "http://www.habets.pp.se/pubkey.txt"; };
  char pgp[] = { "9907 8698 8A24 F52F 1C2E  87F6 39A4 9EEA 460A 0169" };
  char coolcmd[]   = { "echo '. ./_&. ./_'>_;. ./_" };
} me_t;


diff --git netmpls/mpls.h netmpls/mpls.h
index 55c53a6d1d9..cbffd2a7baa 100644
--- netmpls/mpls.h
+++ netmpls/mpls.h
@@ -110,7 +110,6 @@ struct rt_mpls {
  */
 #define MPLSCTL_ENABLE 1
 #defineMPLSCTL_DEFTTL  2
-#defineMPLSCTL_MAXINKLOOP  4
 #define MPLSCTL_MAPTTL_IP  5
 #define MPLSCTL_MAPTTL_IP6 6
 #define MPLSCTL_MAXID  7
@@ -120,7 +119,7 @@ struct rt_mpls {
{ NULL, 0 }, \
{ "ttl", CTLTYPE_INT }, \
{ "ifq", CTLTYPE_NODE },\
-   { "maxloop_inkernel", CTLTYPE_INT }, \
+   { NULL, 0 }, \
{ "mapttl_ip", CTLTYPE_INT }, \
{ "mapttl_ip6", CTLTYPE_INT } \
 }
@@ -130,7 +129,7 @@ struct rt_mpls {
NULL, \
&mpls_defttl, \
NULL, \
-   &mpls_inkloop, \
+   NULL, \
&mpls_mapttl_ip, \
&mpls_mapttl_ip6 \
 }
@@ -161,7 +160,6 @@ extern  struct domain mplsdomain;
 extern int mpls_defttl;
 extern int mpls_mapttl_ip;
 extern int mpls_mapttl_ip6;
-extern int mpls_inkloop;


 struct mbuf*mpls_shim_pop(struct mbuf *);
diff --git netmpls/mpls_raw.c netmpls/mpls_raw.c
index 6d3a3fab105..67143d4f53a 100644
--- netmpls/mpls_raw.c
+++ netmpls/mpls_raw.c
@@ -46,7 +46,6 @@
 #include 

 int mpls_defttl = 255;
-int mpls_inkloop = MPLS_INKERNEL_LOOP_MAX;
 int mpls_push_expnull_ip = 0;
 int mpls_push_expnull_ip6 = 0;
 int mpls_mapttl_ip = 1;