Re: [Patch]: check-lib-depends(1) fix typo in manpage

2019-12-22 Thread Kurt Mosiejczuk
On Sun, Dec 22, 2019 at 05:34:40PM -0800, Lev Lazinskiy wrote:
> Hi everyone, 

> This is my first patch, so I apologize in advance if there are any
> errors. I have been reading every man page for my own benefit and I came
> across a typo in check-lib-depends(1). This patch fixes it. 

> I plan on sending any other fixes that I find, out of curiosity is it
> better to send a new email for every man page, or to batch these up?

> Index: share/man/man1/check-lib-depends.1
> ===
> RCS file: /cvs/src/share/man/man1/check-lib-depends.1,v
> retrieving revision 1.3
> diff -u -p -u -r1.3 check-lib-depends.1
> --- share/man/man1/check-lib-depends.14 Mar 2019 15:25:16 -   
> 1.3
> +++ share/man/man1/check-lib-depends.123 Dec 2019 01:11:41 -
> @@ -44,7 +44,7 @@ from the
>  directory, or look directly inside a
>  .Ar package .
>  .Pp
> -Likewise, it can also verify dependencies off installed packages,
> +Likewise, it can also verify dependencies of installed packages,
>  or figure them out directly from the port directory.
>  .Pp
>  .Nm

Committed. Thanks!

--Kurt



[Patch]: check-lib-depends(1) fix typo in manpage

2019-12-22 Thread Lev Lazinskiy
Hi everyone, 

This is my first patch, so I apologize in advance if there are any
errors. I have been reading every man page for my own benefit and I came
across a typo in check-lib-depends(1). This patch fixes it. 

I plan on sending any other fixes that I find, out of curiosity is it
better to send a new email for every man page, or to batch these up?

Index: share/man/man1/check-lib-depends.1
===
RCS file: /cvs/src/share/man/man1/check-lib-depends.1,v
retrieving revision 1.3
diff -u -p -u -r1.3 check-lib-depends.1
--- share/man/man1/check-lib-depends.1  4 Mar 2019 15:25:16 -   1.3
+++ share/man/man1/check-lib-depends.1  23 Dec 2019 01:11:41 -
@@ -44,7 +44,7 @@ from the
 directory, or look directly inside a
 .Ar package .
 .Pp
-Likewise, it can also verify dependencies off installed packages,
+Likewise, it can also verify dependencies of installed packages,
 or figure them out directly from the port directory.
 .Pp
 .Nm



Re: attention please: host's IP stack behavior got changed slightly

2019-12-22 Thread Alexandr Nedvedicky
Hello,


On Fri, Dec 20, 2019 at 11:12:15PM +0100, Alexander Bluhm wrote:
> On Wed, Dec 18, 2019 at 09:07:35AM +0100, Alexandr Nedvedicky wrote:
> > I see. Updated diff below makes ip6_input_if() to explicitly check
> > for PF_TAG_TRANSLATE_LOCALHOST tag, when ip6_forwarding is disabled.
> >
> > if ip6_forwarding is enabled, then the ip6_input_if() keeps current
> > behavior.
> 
> You have misunderstood my internsion.
> 

Yes, I obviously did. Updated diff is below.



> 
> And the second question, but not for this commit, is why do we
> need this block?
> 
> if (IN6_IS_ADDR_LOOPBACK(>ip6_src) ||
> IN6_IS_ADDR_LOOPBACK(>ip6_dst)) {
> nxt = ip6_ours(mp, offp, nxt, af);
> goto out;
> }
> 
> It was removed in kame here:
> 


It did not come to my mind to check kame project, when seeing
code above. It looks like it has evolved to current shape
from original code below (as committed by itojun@)

+   /*
+* Check with the firewall...
+*/
+   if (ip6_fw_chk_ptr) {
+   u_short port = 0;
+   /* If ipfw says divert, we have to just drop packet */
+   /* use port as a dummy argument */
+   if ((*ip6_fw_chk_ptr)(, NULL, , )) {
+   m_freem(m);
+   m = NULL;
+   }
+   if (!m)
+   return;
+   }
+#endif
+
+   /*
+* Scope check
+*/
+   if (IN6_IS_ADDR_MULTICAST(>ip6_src) ||
+   IN6_IS_ADDR_UNSPECIFIED(>ip6_dst)) {
+   ip6stat.ip6s_badscope++;
+   in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_addrerr);
+   goto bad;
+   }
+   if (IN6_IS_ADDR_LOOPBACK(>ip6_src) ||
+   IN6_IS_ADDR_LOOPBACK(>ip6_dst)) {
+   if (m->m_pkthdr.rcvif->if_flags & IFF_LOOPBACK) {
+   ours = 1;
+   deliverifp = m->m_pkthdr.rcvif;
+   goto hbhcheck;
+   } else {
+   ip6stat.ip6s_badscope++;
+   in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_addrerr);
+   goto bad;
+   }
+   }

It seems to me we should just remove them. You have my OK if you want
to do it. Perhaps intention in earlier change to ip6_input_if() was to
move IN6_IS_ADDR_LOOPBACK() checks before ip6_input_if() calls pf_test()
instead of doing copy'n'modified-paste.

thanks and
regards
sashan

8<---8<---8<--8<
diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c
index 058b2f038fa..f4114f45045 100644
--- a/sys/netinet/ip_input.c
+++ b/sys/netinet/ip_input.c
@@ -753,7 +753,8 @@ in_ouraddr(struct mbuf *m, struct ifnet *ifp, struct 
rtentry **prt)
}
}
} else if (ipforwarding == 0 && rt->rt_ifidx != ifp->if_index &&
-   !((ifp->if_flags & IFF_LOOPBACK) || (ifp->if_type == IFT_ENC))) {
+   !((ifp->if_flags & IFF_LOOPBACK) || (ifp->if_type == IFT_ENC) ||
+   (m->m_pkthdr.pf.flags & PF_TAG_TRANSLATE_LOCALHOST))) {
/* received on wrong interface. */
 #if NCARP > 0
struct ifnet *out_if;
diff --git a/sys/netinet6/ip6_input.c b/sys/netinet6/ip6_input.c
index 5404d7ccfb4..62e92d9c46c 100644
--- a/sys/netinet6/ip6_input.c
+++ b/sys/netinet6/ip6_input.c
@@ -435,7 +435,8 @@ ip6_input_if(struct mbuf **mp, int *offp, int nxt, int af, 
struct ifnet *ifp)
 
if (ip6_forwarding == 0 && rt->rt_ifidx != ifp->if_index &&
!((ifp->if_flags & IFF_LOOPBACK) ||
-   (ifp->if_type == IFT_ENC))) {
+   (ifp->if_type == IFT_ENC)) ||
+   (m->m_pkthdr.pf.flags & PF_TAG_TRANSLATE_LOCALHOST)) {
/* received on wrong interface */
 #if NCARP > 0
struct ifnet *out_if;




Re: ospf6d: add reference to area in struct iface

2019-12-22 Thread Remi Locherer
On Sun, Dec 22, 2019 at 06:35:47PM +0100, Denis Fondras wrote:
> area is now part of struct iface
> 
> Code looks cleaner and more like ospfd.

ok remi@

> 
> Index: area.c
> ===
> RCS file: /cvs/src/usr.sbin/ospf6d/area.c,v
> retrieving revision 1.4
> diff -u -p -r1.4 area.c
> --- area.c28 Dec 2008 20:08:31 -  1.4
> +++ area.c22 Dec 2019 17:18:49 -
> @@ -88,19 +88,24 @@ area_find(struct ospfd_conf *conf, struc
>  }
>  
>  void
> -area_track(struct area *area, int state)
> +area_track(struct area *area)
>  {
> - int old = area->active;
> + int  old = area->active;
> + struct iface*iface;
>  
> - if (state & NBR_STA_FULL)
> - area->active++;
> - else if (area->active == 0)
> - fatalx("area_track: area already inactive");
> - else
> - area->active--;
> -
> - if (area->active == 0 || old == 0)
> + area->active = 0;
> + LIST_FOREACH(iface, >iface_list, entry) {
> + if (iface->state & IF_STA_DOWN)
> + continue;
> + area->active = 1;
> + break;
> + }
> +
> + if (area->active != old) {
> + ospfe_imsg_compose_rde(IMSG_AREA_CHANGE, area->id.s_addr, 0,
> + >active, sizeof(area->active));
>   ospfe_demote_area(area, old == 0);
> + }
>  }
>  
>  int
> @@ -110,7 +115,7 @@ area_border_router(struct ospfd_conf *co
>   int  active = 0;
>  
>   LIST_FOREACH(area, >area_list, entry)
> - if (area->active > 0)
> + if (area->active)
>   active++;
>  
>   return (active > 1);
> @@ -124,5 +129,5 @@ area_ospf_options(struct area *area)
>   if (area && !area->stub)
>   opt |= OSPF_OPTION_E;
>  
> - return opt;
> + return (opt);
>  }
> Index: database.c
> ===
> RCS file: /cvs/src/usr.sbin/ospf6d/database.c,v
> retrieving revision 1.17
> diff -u -p -r1.17 database.c
> --- database.c11 Dec 2019 21:33:56 -  1.17
> +++ database.c22 Dec 2019 17:18:49 -
> @@ -134,8 +134,7 @@ send_db_description(struct nbr *nbr)
>   fatalx("send_db_description: unknown interface type");
>   }
>  
> - dd_hdr.opts = htonl(area_ospf_options(area_find(oeconf,
> - nbr->iface->area_id)));
> + dd_hdr.opts = htonl(area_ospf_options(nbr->iface->area));
>   dd_hdr.bits = bits;
>   dd_hdr.dd_seq_num = htonl(nbr->dd_seq_num);
>  
> Index: hello.c
> ===
> RCS file: /cvs/src/usr.sbin/ospf6d/hello.c,v
> retrieving revision 1.19
> diff -u -p -r1.19 hello.c
> --- hello.c   11 Dec 2019 21:33:56 -  1.19
> +++ hello.c   22 Dec 2019 17:18:49 -
> @@ -72,7 +72,7 @@ send_hello(struct iface *iface)
>   /* hello header */
>   hello.iface_id = htonl(iface->ifindex);
>   LSA_24_SETHI(hello.opts, iface->priority);
> - opts = area_ospf_options(area_find(oeconf, iface->area_id));
> + opts = area_ospf_options(iface->area);
>   LSA_24_SETLO(hello.opts, opts);
>   hello.opts = htonl(hello.opts);
>  
> @@ -148,7 +148,7 @@ recv_hello(struct iface *iface, struct i
>   return;
>   }
>  
> - if ((area = area_find(oeconf, iface->area_id)) == NULL)
> + if ((area = iface->area) == NULL)
>   fatalx("interface lost area");
>  
>   opts = LSA_24_GETLO(ntohl(hello.opts));
> Index: interface.c
> ===
> RCS file: /cvs/src/usr.sbin/ospf6d/interface.c,v
> retrieving revision 1.26
> diff -u -p -r1.26 interface.c
> --- interface.c   22 Dec 2019 15:34:52 -  1.26
> +++ interface.c   22 Dec 2019 17:18:49 -
> @@ -143,6 +143,7 @@ if_fsm(struct iface *iface, enum iface_e
>   iface->state = new_state;
>  
>   if (iface->state != old_state) {
> + area_track(iface->area);
>   orig_rtr_lsa(iface);
>   orig_link_lsa(iface);
>  
> @@ -649,7 +650,7 @@ if_to_ctl(struct iface *iface)
>   memcpy(ictl.name, iface->name, sizeof(ictl.name));
>   memcpy(, >addr, sizeof(ictl.addr));
>   ictl.rtr_id.s_addr = ospfe_router_id();
> - memcpy(, >area_id, sizeof(ictl.area));
> + memcpy(, >area->id, sizeof(ictl.area));
>   if (iface->dr) {
>   memcpy(_id, >dr->id, sizeof(ictl.dr_id));
>   memcpy(_addr, >dr->addr, sizeof(ictl.dr_addr));
> Index: neighbor.c
> ===
> RCS file: /cvs/src/usr.sbin/ospf6d/neighbor.c,v
> retrieving revision 1.14
> diff -u -p -r1.14 neighbor.c
> --- neighbor.c9 Feb 2018 03:53:37 -   1.14
> +++ neighbor.c22 Dec 2019 17:18:49 -
> @@ -202,8 +202,6 @@ nbr_fsm(struct nbr *nbr, enum nbr_event 
> 

scsi_delay(): sleep without lbolt

2019-12-22 Thread Scott Cheloha
If I'm reading this right, the idea is that  gets woken up once
a second with wakeup(9), so scsi_delay() uses that to sleep roughly the
given number of seconds.

It seems needlessly convoluted.  Can't we just sleep for the given
number of seconds directly and check for a signal?  Without ?

Index: scsi_base.c
===
RCS file: /cvs/src/sys/scsi/scsi_base.c,v
retrieving revision 1.260
diff -u -p -r1.260 scsi_base.c
--- scsi_base.c 6 Dec 2019 13:53:26 -   1.260
+++ scsi_base.c 22 Dec 2019 22:14:51 -
@@ -1559,6 +1559,8 @@ scsi_xs_error(struct scsi_xfer *xs)
 int
 scsi_delay(struct scsi_xfer *xs, int seconds)
 {
+   int ret;
+
switch (xs->flags & (SCSI_POLL | SCSI_NOSLEEP)) {
case SCSI_POLL:
delay(100 * seconds);
@@ -1571,12 +1573,11 @@ scsi_delay(struct scsi_xfer *xs, int sec
return EIO;
}
 
-   while (seconds-- > 0) {
-   if (tsleep_nsec(, PRIBIO|PCATCH, "scbusy", INFSLP)) {
-   /* Signal == abort xs. */
-   return EIO;
-   }
-   }
+   ret = tsleep_nsec(, PRIBIO|PCATCH, "scbusy", SEC_TO_NSEC(seconds));
+
+   /* Signal == abort xs. */
+   if (ret == ERESTART || ret == EINTR)
+   return EIO;
 
return ERESTART;
 }



pluart(4): timeout_add(9) -> timeout_add_sec(9)

2019-12-22 Thread Scott Cheloha
ok?

Index: pluart.c
===
RCS file: /cvs/src/sys/dev/ic/pluart.c,v
retrieving revision 1.4
diff -u -p -r1.4 pluart.c
--- pluart.c11 Aug 2019 10:03:32 -  1.4
+++ pluart.c22 Dec 2019 21:32:50 -
@@ -225,7 +225,7 @@ pluart_intr(void *arg)
if (p >= sc->sc_ibufend) {
sc->sc_floods++;
if (sc->sc_errors++ == 0)
-   timeout_add(>sc_diag_tmo, 60 * hz);
+   timeout_add_sec(>sc_diag_tmo, 60);
} else {
*p++ = c;
if (p == sc->sc_ibufhigh && ISSET(tp->t_cflag, 
CRTSCTS)) {
@@ -428,7 +428,7 @@ pluart_softint(void *arg)
if (ISSET(c, IMXUART_RX_OVERRUN)) {
sc->sc_overflows++;
if (sc->sc_errors++ == 0)
-   timeout_add(>sc_diag_tmo, 60 * hz);
+   timeout_add_sec(>sc_diag_tmo, 60);
}
*/
/* This is ugly, but fast. */
@@ -605,7 +605,7 @@ pluartclose(dev_t dev, int flag, int mod
/* tty device is waiting for carrier; drop dtr then re-raise */
//CLR(sc->sc_ucr3, IMXUART_CR3_DSR);
//bus_space_write_4(iot, ioh, IMXUART_UCR3, sc->sc_ucr3);
-   timeout_add(>sc_dtr_tmo, hz * 2);
+   timeout_add_sec(>sc_dtr_tmo, 2);
} else {
/* no one else waiting; turn off the uart */
pluart_pwroff(sc);



Re: ospf6d: warn when a neighbor changes its source address

2019-12-22 Thread Denis Fondras
On Sun, Dec 22, 2019 at 10:06:40PM +0100, Remi Locherer wrote:
> this is similar to ospfd's hello.c rev 1.23.
> 
> OK?
> 
> Remi
> 
> 
> Index: hello.c
> ===
> RCS file: /cvs/src/usr.sbin/ospf6d/hello.c,v
> retrieving revision 1.19
> diff -u -p -r1.19 hello.c
> --- hello.c   11 Dec 2019 21:33:56 -  1.19
> +++ hello.c   22 Dec 2019 20:46:01 -
> @@ -173,10 +173,16 @@ recv_hello(struct iface *iface, struct i
>   nbr->dr.s_addr = hello.d_rtr;
>   nbr->bdr.s_addr = hello.bd_rtr;
>   nbr->priority = LSA_24_GETHI(ntohl(hello.opts));
> + /* XXX neighbor address shouldn't be stored on virtual links */
> + nbr->addr = *src;
> + }
> +
> + if (memcmp(>addr, src, sizeof(struct in6_addr)) != 0) {

Can you use IN6_ARE_ADDR_EQUAL() macro instead of memcmp() to be consistent with
other address comparison ?

Otherwise OK denis@

> + log_warnx("%s: neighbor ID %s changed its address to %s",
> + __func__, inet_ntoa(nbr->id), log_in6addr(src));
> + nbr->addr = *src;
>   }
>  
> - /* actually the neighbor address shouldn't be stored on virtual links */
> - nbr->addr = *src;
>   nbr->options = opts;
>  
>   nbr_fsm(nbr, NBR_EVT_HELLO_RCVD);
> 



ospf6d: warn when a neighbor changes its source address

2019-12-22 Thread Remi Locherer
this is similar to ospfd's hello.c rev 1.23.

OK?

Remi


Index: hello.c
===
RCS file: /cvs/src/usr.sbin/ospf6d/hello.c,v
retrieving revision 1.19
diff -u -p -r1.19 hello.c
--- hello.c 11 Dec 2019 21:33:56 -  1.19
+++ hello.c 22 Dec 2019 20:46:01 -
@@ -173,10 +173,16 @@ recv_hello(struct iface *iface, struct i
nbr->dr.s_addr = hello.d_rtr;
nbr->bdr.s_addr = hello.bd_rtr;
nbr->priority = LSA_24_GETHI(ntohl(hello.opts));
+   /* XXX neighbor address shouldn't be stored on virtual links */
+   nbr->addr = *src;
+   }
+
+   if (memcmp(>addr, src, sizeof(struct in6_addr)) != 0) {
+   log_warnx("%s: neighbor ID %s changed its address to %s",
+   __func__, inet_ntoa(nbr->id), log_in6addr(src));
+   nbr->addr = *src;
}
 
-   /* actually the neighbor address shouldn't be stored on virtual links */
-   nbr->addr = *src;
nbr->options = opts;
 
nbr_fsm(nbr, NBR_EVT_HELLO_RCVD);



ospf6d: add basic regress tests

2019-12-22 Thread Denis Fondras
Add basic regress test to ospf6d.

Index: ospf6d/Makefile
===
RCS file: ospf6d/Makefile
diff -N ospf6d/Makefile
--- /dev/null   1 Jan 1970 00:00:00 -
+++ ospf6d/Makefile 22 Dec 2019 19:27:27 -
@@ -0,0 +1,10 @@
+# $OpenBSD$
+
+REGRESS_TARGETS=   network_statement
+
+OSPF6D ?=  /usr/sbin/ospf6d
+
+network_statement:
+   ${SUDO} ksh ${.CURDIR}/$@.sh ${OSPF6D} ${.CURDIR} 11 12 pair11 pair12
+
+.include 
Index: ospf6d/network_statement.sh
===
RCS file: ospf6d/network_statement.sh
diff -N ospf6d/network_statement.sh
--- /dev/null   1 Jan 1970 00:00:00 -
+++ ospf6d/network_statement.sh 22 Dec 2019 19:27:27 -
@@ -0,0 +1,107 @@
+#!/bin/ksh
+#  $OpenBSD$
+set -e
+
+OSPF6D=$1
+OSPF6DCONFIGDIR=$2
+RDOMAIN1=$3
+RDOMAIN2=$4
+PAIR1=$5
+PAIR2=$6
+
+RDOMAINS="${RDOMAIN1} ${RDOMAIN2}"
+PAIRS="${PAIR1} ${PAIR2}"
+PAIR1IP=2001:db8::${RDOMAIN1}
+PAIR2IP=2001:db8::${RDOMAIN2}
+PAIR1PREFIX=2001:db8:${RDOMAIN1}::
+PAIR2PREFIX=2001:db8:${RDOMAIN2}::
+PAIR2PREFIX2=2001:db8:${RDOMAIN2}:${RDOMAIN2}::
+
+error_notify() {
+   echo cleanup
+   pkill -T ${RDOMAIN1} ospf6d || true
+   pkill -T ${RDOMAIN2} ospf6d || true
+   sleep 1
+   ifconfig ${PAIR2} destroy || true
+   ifconfig ${PAIR1} destroy || true
+   ifconfig vether${RDOMAIN1} destroy || true
+   ifconfig vether${RDOMAIN2} destroy || true
+   route -qn -T ${RDOMAIN1} flush || true
+   route -qn -T ${RDOMAIN2} flush || true
+   ifconfig lo${RDOMAIN1} destroy || true
+   ifconfig lo${RDOMAIN2} destroy || true
+   rm ospf6d.1.conf ospf6d.2.conf
+   if [ $1 -ne 0 ]; then
+   echo FAILED
+   exit 1
+   else
+   echo SUCCESS
+   fi
+}
+
+if [ "$(id -u)" -ne 0 ]; then 
+   echo need root privileges >&2
+   exit 1
+fi
+
+trap 'error_notify $?' EXIT
+
+echo check if rdomains are busy
+for n in ${RDOMAINS}; do
+   if /sbin/ifconfig | grep -v "^lo${n}:" | grep " rdomain ${n} "; then
+   echo routing domain ${n} is already used >&2
+   exit 1
+   fi
+done
+
+echo check if interfaces are busy
+for n in ${PAIRS}; do
+   /sbin/ifconfig "${n}" >/dev/null 2>&1 && \
+   ( echo interface ${n} is already used >&2; exit 1 )
+done
+
+set -x
+
+echo setup
+ifconfig ${PAIR1} inet6 rdomain ${RDOMAIN1} ${PAIR1IP}/64 up
+ifconfig ${PAIR2} inet6 rdomain ${RDOMAIN2} ${PAIR2IP}/64 up
+ifconfig ${PAIR1} patch ${PAIR2}
+ifconfig lo${RDOMAIN1} inet 127.0.0.1/8
+ifconfig lo${RDOMAIN2} inet 127.0.0.1/8
+ifconfig vether${RDOMAIN1} inet6 rdomain ${RDOMAIN1} ${PAIR1PREFIX}/64 up
+ifconfig vether${RDOMAIN2} inet6 rdomain ${RDOMAIN2} ${PAIR2PREFIX}/64 up
+ifconfig vether${RDOMAIN2} inet6 rdomain ${RDOMAIN2} ${PAIR2PREFIX2}/64 up
+sed "s/{RDOMAIN1}/${RDOMAIN1}/g;s/{PAIR1}/${PAIR1}/g" \
+ospf6d.network_statement.rdomain1.conf > ospf6d.1.conf
+chmod 0600 ospf6d.1.conf
+sed "s/{RDOMAIN2}/${RDOMAIN2}/g;s/{PAIR2}/${PAIR2}/g" \
+ospf6d.network_statement.rdomain2.conf > ospf6d.2.conf
+chmod 0600 ospf6d.2.conf 
+
+echo add routes
+route -T ${RDOMAIN2} add -inet6 default ${PAIR2PREFIX}1
+route -T ${RDOMAIN2} add 2001:db8:::/126 ${PAIR2PREFIX}2
+route -T ${RDOMAIN2} add 2001:db8:fffe::/64 ${PAIR2PREFIX}3 -label toOSPF
+
+echo start ospf6d
+route -T ${RDOMAIN1} exec ${OSPF6D} \
+-v -f ${OSPF6DCONFIGDIR}/ospf6d.1.conf
+route -T ${RDOMAIN2} exec ${OSPF6D} \
+-v -f ${OSPF6DCONFIGDIR}/ospf6d.2.conf
+
+sleep 120
+
+echo tests
+route -T ${RDOMAIN1} exec ospf6ctl sh fib
+route -T ${RDOMAIN1} exec ospf6ctl sh rib | \
+grep ${PAIR2PREFIX}/64
+route -T ${RDOMAIN1} exec ospf6ctl sh rib | \
+grep ${PAIR2PREFIX2}/64
+route -T ${RDOMAIN1} exec ospf6ctl sh rib | \
+grep "2001:db8:::/126"
+route -T ${RDOMAIN1} exec ospf6ctl sh rib | \
+grep "::/0"
+route -T ${RDOMAIN1} exec ospf6ctl sh rib | \
+grep "2001:db8:fffe::/64"
+
+exit 0
Index: ospf6d/ospf6d.network_statement.rdomain1.conf
===
RCS file: ospf6d/ospf6d.network_statement.rdomain1.conf
diff -N ospf6d/ospf6d.network_statement.rdomain1.conf
--- /dev/null   1 Jan 1970 00:00:00 -
+++ ospf6d/ospf6d.network_statement.rdomain1.conf   22 Dec 2019 19:27:27 
-
@@ -0,0 +1,10 @@
+router-id 1.1.1.1
+rdomain {RDOMAIN1}
+
+fib-priority 62
+
+area 10.0.0.1 {
+   interface lo{RDOMAIN1}
+   interface vether{RDOMAIN1}
+   interface {PAIR1}
+}
Index: ospf6d/ospf6d.network_statement.rdomain2.conf
===
RCS file: ospf6d/ospf6d.network_statement.rdomain2.conf
diff -N ospf6d/ospf6d.network_statement.rdomain2.conf
--- /dev/null   1 Jan 1970 00:00:00 -
+++ ospf6d/ospf6d.network_statement.rdomain2.conf   22 Dec 2019 19:27:27 
-
@@ -0,0 +1,12 @@
+router-id 2.2.2.2
+rdomain 

sunkbd: timeout_add(9) -> timeout_add_msec(9)

2019-12-22 Thread Scott Cheloha
As per dev/wscons/wsconsio.h, wskbd_bell_data.period is a count of
milliseconds.

ok?

Index: sunkbd.c
===
RCS file: /cvs/src/sys/dev/sun/sunkbd.c,v
retrieving revision 1.27
diff -u -p -r1.27 sunkbd.c
--- sunkbd.c19 Mar 2016 11:41:56 -  1.27
+++ sunkbd.c22 Dec 2019 19:28:46 -
@@ -84,7 +84,7 @@ sunkbd_attach(struct sunkbd_softc *sc, s
 void
 sunkbd_bell(struct sunkbd_softc *sc, u_int period, u_int pitch, u_int volume)
 {
-   int nticks, s;
+   int s;
u_int8_t c = SKBD_CMD_BELLON;
 
 #if NTCTRL > 0
@@ -103,14 +103,10 @@ sunkbd_bell(struct sunkbd_softc *sc, u_i
return;
}
if (sc->sc_bellactive == 0) {
-   nticks = (period * hz) / 1000;
-   if (nticks <= 0)
-   nticks = 1;
-
sc->sc_bellactive = 1;
sc->sc_belltimeout = 1;
(*sc->sc_sendcmd)(sc, , 1);
-   timeout_add(>sc_bellto, nticks);
+   timeout_add_msec(>sc_bellto, period);
}
splx(s);
 }



lcd(4/hppa): timeout_add(9) -> timeout_add_usec(9)

2019-12-22 Thread Scott Cheloha
lcd_softc.sc_delay's unit appears to be microseconds.

ok?

Index: lcd.c
===
RCS file: /cvs/src/sys/arch/hppa/dev/lcd.c,v
retrieving revision 1.4
diff -u -p -r1.4 lcd.c
--- lcd.c   11 Dec 2015 16:07:01 -  1.4
+++ lcd.c   22 Dec 2019 19:16:31 -
@@ -138,7 +138,7 @@ lcd_blink(void *v, int on)
 
sc->sc_on = on;
bus_space_write_1(sc->sc_iot, sc->sc_cmdh, 0, sc->sc_heartbeat[0]);
-   timeout_add(>sc_to, max(1, (sc->sc_delay * hz) / 100));
+   timeout_add_usec(>sc_to, sc->sc_delay);
 }
 
 void



Re: Dell PowerEdge R7515

2019-12-22 Thread Hrvoje Popovski
On 20.12.2019. 16:45, Hrvoje Popovski wrote:
> Hi,
> 
> installation went very well but i can't reboot or halt box, it stops at
> syncing disks... done  and i need to power off ..
> 

cpu on that box is 32/64 cores, when HT is enabled i'm seeing this log

Dec 22 19:53:46 r7515 /bsd: klog: dropped 3272 bytes, message buffer full

first line in dmesg starts from here ..

r7515# dmesg
36,CFLUSH,MMX,FXSR,SSE,SSE2,HTT,SSE3,PCLMUL,MWAIT,SSSE3,FMA3,CX16,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,AES,XSAVE,AVX,F16C,RDRAND,NXE,MMXX,FFXSR,PAGE1GB,RDTSCP,LONG,LAHF,CMPLEG,SVM,EAPICSP,AMCR8,ABM,SSE4A,MASSE,3DNOWP,OSVW,IBS,SKINIT,TCE,TOPEXT,CPCTR,DBKP,PCTRL3,MWAITX,ITSC,FSGSBASE,BMI1,AVX2,SMEP,BMI2,PQM,RDSEED,ADX,SMAP,CLFLUSHOPT,CLWB,SHA,UMIP,IBPB,IBRS,STIBP,SSBD,XSAVEOPT,XSAVEC,XGETBV1,XSAVES
cpu2: 32KB 64b/line 8-way I-cache, 32KB 64b/line 8-way D-cache, 512KB
64b/line 8-way L2 cache, 128MB 64b/line disabled L3 cache
cpu2: ITLB 64 4KB entries fully associative, 64 4MB entries fully
associative
cpu2: DTLB 64 4KB entries fully associative, 64 4MB entries fully
associative
cpu2: smt 0, core 2, package 0




ospf6d: add reference to area in struct iface

2019-12-22 Thread Denis Fondras
area is now part of struct iface

Code looks cleaner and more like ospfd.

Index: area.c
===
RCS file: /cvs/src/usr.sbin/ospf6d/area.c,v
retrieving revision 1.4
diff -u -p -r1.4 area.c
--- area.c  28 Dec 2008 20:08:31 -  1.4
+++ area.c  22 Dec 2019 17:18:49 -
@@ -88,19 +88,24 @@ area_find(struct ospfd_conf *conf, struc
 }
 
 void
-area_track(struct area *area, int state)
+area_track(struct area *area)
 {
-   int old = area->active;
+   int  old = area->active;
+   struct iface*iface;
 
-   if (state & NBR_STA_FULL)
-   area->active++;
-   else if (area->active == 0)
-   fatalx("area_track: area already inactive");
-   else
-   area->active--;
-
-   if (area->active == 0 || old == 0)
+   area->active = 0;
+   LIST_FOREACH(iface, >iface_list, entry) {
+   if (iface->state & IF_STA_DOWN)
+   continue;
+   area->active = 1;
+   break;
+   }
+
+   if (area->active != old) {
+   ospfe_imsg_compose_rde(IMSG_AREA_CHANGE, area->id.s_addr, 0,
+   >active, sizeof(area->active));
ospfe_demote_area(area, old == 0);
+   }
 }
 
 int
@@ -110,7 +115,7 @@ area_border_router(struct ospfd_conf *co
int  active = 0;
 
LIST_FOREACH(area, >area_list, entry)
-   if (area->active > 0)
+   if (area->active)
active++;
 
return (active > 1);
@@ -124,5 +129,5 @@ area_ospf_options(struct area *area)
if (area && !area->stub)
opt |= OSPF_OPTION_E;
 
-   return opt;
+   return (opt);
 }
Index: database.c
===
RCS file: /cvs/src/usr.sbin/ospf6d/database.c,v
retrieving revision 1.17
diff -u -p -r1.17 database.c
--- database.c  11 Dec 2019 21:33:56 -  1.17
+++ database.c  22 Dec 2019 17:18:49 -
@@ -134,8 +134,7 @@ send_db_description(struct nbr *nbr)
fatalx("send_db_description: unknown interface type");
}
 
-   dd_hdr.opts = htonl(area_ospf_options(area_find(oeconf,
-   nbr->iface->area_id)));
+   dd_hdr.opts = htonl(area_ospf_options(nbr->iface->area));
dd_hdr.bits = bits;
dd_hdr.dd_seq_num = htonl(nbr->dd_seq_num);
 
Index: hello.c
===
RCS file: /cvs/src/usr.sbin/ospf6d/hello.c,v
retrieving revision 1.19
diff -u -p -r1.19 hello.c
--- hello.c 11 Dec 2019 21:33:56 -  1.19
+++ hello.c 22 Dec 2019 17:18:49 -
@@ -72,7 +72,7 @@ send_hello(struct iface *iface)
/* hello header */
hello.iface_id = htonl(iface->ifindex);
LSA_24_SETHI(hello.opts, iface->priority);
-   opts = area_ospf_options(area_find(oeconf, iface->area_id));
+   opts = area_ospf_options(iface->area);
LSA_24_SETLO(hello.opts, opts);
hello.opts = htonl(hello.opts);
 
@@ -148,7 +148,7 @@ recv_hello(struct iface *iface, struct i
return;
}
 
-   if ((area = area_find(oeconf, iface->area_id)) == NULL)
+   if ((area = iface->area) == NULL)
fatalx("interface lost area");
 
opts = LSA_24_GETLO(ntohl(hello.opts));
Index: interface.c
===
RCS file: /cvs/src/usr.sbin/ospf6d/interface.c,v
retrieving revision 1.26
diff -u -p -r1.26 interface.c
--- interface.c 22 Dec 2019 15:34:52 -  1.26
+++ interface.c 22 Dec 2019 17:18:49 -
@@ -143,6 +143,7 @@ if_fsm(struct iface *iface, enum iface_e
iface->state = new_state;
 
if (iface->state != old_state) {
+   area_track(iface->area);
orig_rtr_lsa(iface);
orig_link_lsa(iface);
 
@@ -649,7 +650,7 @@ if_to_ctl(struct iface *iface)
memcpy(ictl.name, iface->name, sizeof(ictl.name));
memcpy(, >addr, sizeof(ictl.addr));
ictl.rtr_id.s_addr = ospfe_router_id();
-   memcpy(, >area_id, sizeof(ictl.area));
+   memcpy(, >area->id, sizeof(ictl.area));
if (iface->dr) {
memcpy(_id, >dr->id, sizeof(ictl.dr_id));
memcpy(_addr, >dr->addr, sizeof(ictl.dr_addr));
Index: neighbor.c
===
RCS file: /cvs/src/usr.sbin/ospf6d/neighbor.c,v
retrieving revision 1.14
diff -u -p -r1.14 neighbor.c
--- neighbor.c  9 Feb 2018 03:53:37 -   1.14
+++ neighbor.c  22 Dec 2019 17:18:49 -
@@ -202,8 +202,6 @@ nbr_fsm(struct nbr *nbr, enum nbr_event 
 * neighbor changed from/to FULL
 * originate new rtr and net LSA
 */
-   area_track(area_find(oeconf, nbr->iface->area_id),
-   nbr->state);

Add /dev/ipmi0 on arm64

2019-12-22 Thread Mark Kettenis
ok?

Index: etc/etc.arm64/MAKEDEV.md
===
RCS file: /cvs/src/etc/etc.arm64/MAKEDEV.md,v
retrieving revision 1.4
diff -u -p -r1.4 MAKEDEV.md
--- etc/etc.arm64/MAKEDEV.md17 Dec 2019 13:08:55 -  1.4
+++ etc/etc.arm64/MAKEDEV.md22 Dec 2019 16:14:19 -
@@ -66,6 +66,7 @@ _DEV(fdesc, 22)
 _DEV(fuse, 92)
 _DEV(gpio, 88)
 _DEV(hotplug, 82)
+_DEV(ipmi, 96)
 dnl _DEV(joy, 26)
 _DEV(pci, 72)
 _DEV(pf, 73)
@@ -110,5 +111,6 @@ target(all, sd, 0, 1, 2, 3, 4, 5, 6, 7, 
 target(all, vnd, 0, 1, 2, 3)dnl
 target(all, bktr, 0)dnl
 target(all, gpio, 0, 1, 2)dnl
+target(all, ipmi, 0)dnl
 target(all, switch, 0, 1, 2, 3)dnl
 twrget(ramd, wsdisp, ttyC, 0)dnl
Index: sys/arch/arm64/arm64/conf.c
===
RCS file: /cvs/src/sys/arch/arm64/arm64/conf.c,v
retrieving revision 1.9
diff -u -p -r1.9 conf.c
--- sys/arch/arm64/arm64/conf.c 17 Dec 2019 13:08:55 -  1.9
+++ sys/arch/arm64/arm64/conf.c 22 Dec 2019 16:14:19 -
@@ -146,6 +146,7 @@ cdev_decl(pci);
 #include "fuse.h"
 #include "openprom.h"
 #include "gpio.h"
+#include "ipmi.h"
 #include "switch.h"
 
 struct cdevsw  cdevsw[] =
@@ -254,7 +255,7 @@ struct cdevsw   cdevsw[] =
cdev_tun_init(NTUN,tap),/* 93: Ethernet network tunnel */
cdev_notdef(),  /* 94 */
cdev_notdef(),  /* 95 */
-   cdev_notdef(),  /* 96 */
+   cdev_ipmi_init(NIPMI,ipmi), /* 96: ipmi */
cdev_switch_init(NSWITCH,switch), /* 97: switch(4) control interface */
cdev_fido_init(NFIDO,fido), /* 98: FIDO/U2F security key */
 };



dwiic(4) improvements

2019-12-22 Thread Mark Kettenis
The diff below contains a couple of improvements to dwiic(4).  They're
mostly for making ipmi(4) on the Ampere/Lenovo arm64 boxes work
better.  But they need testing on x86 machines with
keyboards.touchpads/touchscreens connected over i2c.

Most of the diff is there to properly implement SMBus block write/read
transactions.  Defines for these are taken from NetBSD (even though
NetBSD doesn't actually implement these).  Nothing special needs to
been done for block writes, but for block reads the slave device sends
us byte count before sending us the data bytes.  So the code is
changed such that we read the byte count first and then adjust the
length of the transaction accordingly.

The diff then uses this support for block reads in the ipmi(4) SSIF
interface code and adds support for multi-part read transactions on
top of that.  That makes ipmi(4) fully functional on the arm64 machine
mentioned above.

Well, almost.  I found that dwiic(4) still craps out every now and
then on this machine.  Limiting the number of commands we send to the
controller to the size of the Tx FIFO minus one seems to help.

Will probably split up the diff before committing.

ok?


Index: dev/i2c/i2c_io.h
===
RCS file: /cvs/src/sys/dev/i2c/i2c_io.h,v
retrieving revision 1.1
diff -u -p -r1.1 i2c_io.h
--- dev/i2c/i2c_io.h23 May 2004 17:33:43 -  1.1
+++ dev/i2c/i2c_io.h22 Dec 2019 15:40:28 -
@@ -1,5 +1,5 @@
 /* $OpenBSD: i2c_io.h,v 1.1 2004/05/23 17:33:43 grange Exp $   */
-/* $NetBSD: i2c_io.h,v 1.1 2003/09/30 00:35:31 thorpej Exp $   */
+/* $NetBSD: i2c_io.h,v 1.3 2012/04/22 14:10:36 pgoyette Exp $  */
 
 /*
  * Copyright (c) 2003 Wasabi Systems, Inc.
@@ -45,16 +45,24 @@
 typedef uint16_t i2c_addr_t;
 
 /* High-level I2C operations. */
+#defineI2C_OPMASK_STOP 1
+#defineI2C_OPMASK_WRITE2
+#defineI2C_OPMASK_BLKMODE  4
+
+#defineI2C_OP_STOP_P(x)(((int)(x) & I2C_OPMASK_STOP) != 0)
+#defineI2C_OP_WRITE_P(x)   (((int)(x) & I2C_OPMASK_WRITE) != 0)
+#defineI2C_OP_READ_P(x)(!I2C_OP_WRITE_P(x))
+#defineI2C_OP_BLKMODE_P(x) (((int)(x) & I2C_OPMASK_BLKMODE) != 0)
+
 typedef enum {
-   I2C_OP_READ = 0,
-   I2C_OP_READ_WITH_STOP   = 1,
-   I2C_OP_WRITE= 2,
-   I2C_OP_WRITE_WITH_STOP  = 3,
+I2C_OP_READ= 0,
+I2C_OP_READ_WITH_STOP  = I2C_OPMASK_STOP,
+I2C_OP_WRITE   = I2C_OPMASK_WRITE,
+I2C_OP_WRITE_WITH_STOP = I2C_OPMASK_WRITE   | I2C_OPMASK_STOP,
+I2C_OP_READ_BLOCK  = I2C_OPMASK_BLKMODE | I2C_OPMASK_STOP,
+I2C_OP_WRITE_BLOCK = I2C_OPMASK_BLKMODE | I2C_OPMASK_WRITE |
+   I2C_OPMASK_STOP,
 } i2c_op_t;
-
-#defineI2C_OP_READ_P(x)(((int)(x) & 2) == 0)
-#defineI2C_OP_WRITE_P(x)   (! I2C_OP_READ_P(x))
-#defineI2C_OP_STOP_P(x)(((int)(x) & 1) != 0)
 
 /*
  * This structure describes a single I2C control script fragment.
Index: dev/i2c/ipmi_i2c.c
===
RCS file: /cvs/src/sys/dev/i2c/ipmi_i2c.c,v
retrieving revision 1.2
diff -u -p -r1.2 ipmi_i2c.c
--- dev/i2c/ipmi_i2c.c  3 Sep 2019 09:17:10 -   1.2
+++ dev/i2c/ipmi_i2c.c  22 Dec 2019 15:40:28 -
@@ -170,7 +170,7 @@ ssif_sendmsg(struct ipmi_cmd *c)
cmd[0] = 2;
cmd[1] = c->c_txlen;
for (retry = 0; retry < 5; retry++) {
-   error = iic_exec(sc->sc_tag, I2C_OP_WRITE_WITH_STOP,
+   error = iic_exec(sc->sc_tag, I2C_OP_WRITE_BLOCK,
sc->sc_addr, cmd, sizeof(cmd), buf, c->c_txlen, 0);
if (!error)
break;
@@ -185,28 +185,72 @@ int
 ssif_recvmsg(struct ipmi_cmd *c)
 {
struct ipmi_i2c_softc *sc = (struct ipmi_i2c_softc *)c->c_sc;
-   uint8_t buf[IPMI_MAX_RX + 16];
+   uint8_t buf[33];
uint8_t cmd[1];
+   uint8_t len;
int error, retry;
-
-   /* We only support single-part reads. */
-   if (c->c_maxrxlen > 32)
-   return -1;
+   int blkno = 0;
 
iic_acquire_bus(sc->sc_tag, 0);
 
cmd[0] = 3;
for (retry = 0; retry < 250; retry++) {
-   memset(buf, 0, c->c_maxrxlen + 1);
-   error = iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP,
-   sc->sc_addr, cmd, sizeof(cmd), buf, c->c_maxrxlen + 1, 0);
-   if (!error) {
-   c->c_rxlen = buf[0];
-   memcpy(sc->sc.sc_buf, [1], c->c_maxrxlen);
+   memset(buf, 0, sizeof(buf));
+   error = iic_exec(sc->sc_tag, I2C_OP_READ_BLOCK,
+   sc->sc_addr, cmd, sizeof(cmd), buf, sizeof(buf), 0);
+   if (error)
+   continue;
+
+   if (buf[0] < 1 || buf[0] > 32) {
+

Re: ospf6d: scale send buffer

2019-12-22 Thread Remi Locherer
On Sun, Dec 22, 2019 at 03:27:05PM +0100, Denis Fondras wrote:
> Trivial diff to scale send buffer on socket.

ok remi@

> 
> Index: interface.c
> ===
> RCS file: /cvs/src/usr.sbin/ospf6d/interface.c,v
> retrieving revision 1.25
> diff -u -p -r1.25 interface.c
> --- interface.c   28 Jun 2019 13:32:49 -  1.25
> +++ interface.c   22 Dec 2019 14:09:20 -
> @@ -708,7 +708,7 @@ if_to_ctl(struct iface *iface)
>  
>  /* misc */
>  void
> -if_set_recvbuf(int fd)
> +if_set_sockbuf(int fd)
>  {
>   int bsize;
>  
> @@ -718,7 +718,15 @@ if_set_recvbuf(int fd)
>   bsize /= 2;
>  
>   if (bsize != 256 * 1024)
> - log_warnx("if_set_recvbuf: recvbuf size only %d", bsize);
> + log_warnx("if_set_sockbuf: recvbuf size only %d", bsize);
> +
> + bsize = 64 * 1024;
> + while (setsockopt(fd, SOL_SOCKET, SO_SNDBUF, ,
> + sizeof(bsize)) == -1)
> + bsize /= 2;
> +
> + if (bsize != 64 * 1024)
> + log_warnx("if_set_sockbuf: sendbuf size only %d", bsize);
>  }
>  
>  int
> Index: ospfe.c
> ===
> RCS file: /cvs/src/usr.sbin/ospf6d/ospfe.c,v
> retrieving revision 1.56
> diff -u -p -r1.56 ospfe.c
> --- ospfe.c   11 Jun 2019 05:00:09 -  1.56
> +++ ospfe.c   22 Dec 2019 14:09:20 -
> @@ -99,7 +99,7 @@ ospfe(struct ospfd_conf *xconf, int pipe
>   fatal("if_set_ipv6_checksum");
>   if (if_set_ipv6_pktinfo(xconf->ospf_socket, 1) == -1)
>   fatal("if_set_ipv6_pktinfo");
> - if_set_recvbuf(xconf->ospf_socket);
> + if_set_sockbuf(xconf->ospf_socket);
>  
>   oeconf = xconf;
>   if (oeconf->flags & OSPFD_FLAG_NO_FIB_UPDATE)
> Index: ospfe.h
> ===
> RCS file: /cvs/src/usr.sbin/ospf6d/ospfe.h,v
> retrieving revision 1.20
> diff -u -p -r1.20 ospfe.h
> --- ospfe.h   11 Dec 2019 21:33:56 -  1.20
> +++ ospfe.h   22 Dec 2019 14:09:20 -
> @@ -142,7 +142,7 @@ struct ctl_iface  *if_to_ctl(struct iface
>  int   if_join_group(struct iface *, struct in6_addr *);
>  int   if_leave_group(struct iface *, struct in6_addr *);
>  int   if_set_mcast(struct iface *);
> -void  if_set_recvbuf(int);
> +void  if_set_sockbuf(int);
>  int   if_set_mcast_loop(int);
>  int   if_set_ipv6_pktinfo(int, int);
>  int   if_set_ipv6_checksum(int);
> 



ospf6d: scale send buffer

2019-12-22 Thread Denis Fondras
Trivial diff to scale send buffer on socket.

Index: interface.c
===
RCS file: /cvs/src/usr.sbin/ospf6d/interface.c,v
retrieving revision 1.25
diff -u -p -r1.25 interface.c
--- interface.c 28 Jun 2019 13:32:49 -  1.25
+++ interface.c 22 Dec 2019 14:09:20 -
@@ -708,7 +708,7 @@ if_to_ctl(struct iface *iface)
 
 /* misc */
 void
-if_set_recvbuf(int fd)
+if_set_sockbuf(int fd)
 {
int bsize;
 
@@ -718,7 +718,15 @@ if_set_recvbuf(int fd)
bsize /= 2;
 
if (bsize != 256 * 1024)
-   log_warnx("if_set_recvbuf: recvbuf size only %d", bsize);
+   log_warnx("if_set_sockbuf: recvbuf size only %d", bsize);
+
+   bsize = 64 * 1024;
+   while (setsockopt(fd, SOL_SOCKET, SO_SNDBUF, ,
+   sizeof(bsize)) == -1)
+   bsize /= 2;
+
+   if (bsize != 64 * 1024)
+   log_warnx("if_set_sockbuf: sendbuf size only %d", bsize);
 }
 
 int
Index: ospfe.c
===
RCS file: /cvs/src/usr.sbin/ospf6d/ospfe.c,v
retrieving revision 1.56
diff -u -p -r1.56 ospfe.c
--- ospfe.c 11 Jun 2019 05:00:09 -  1.56
+++ ospfe.c 22 Dec 2019 14:09:20 -
@@ -99,7 +99,7 @@ ospfe(struct ospfd_conf *xconf, int pipe
fatal("if_set_ipv6_checksum");
if (if_set_ipv6_pktinfo(xconf->ospf_socket, 1) == -1)
fatal("if_set_ipv6_pktinfo");
-   if_set_recvbuf(xconf->ospf_socket);
+   if_set_sockbuf(xconf->ospf_socket);
 
oeconf = xconf;
if (oeconf->flags & OSPFD_FLAG_NO_FIB_UPDATE)
Index: ospfe.h
===
RCS file: /cvs/src/usr.sbin/ospf6d/ospfe.h,v
retrieving revision 1.20
diff -u -p -r1.20 ospfe.h
--- ospfe.h 11 Dec 2019 21:33:56 -  1.20
+++ ospfe.h 22 Dec 2019 14:09:20 -
@@ -142,7 +142,7 @@ struct ctl_iface*if_to_ctl(struct iface
 int if_join_group(struct iface *, struct in6_addr *);
 int if_leave_group(struct iface *, struct in6_addr *);
 int if_set_mcast(struct iface *);
-voidif_set_recvbuf(int);
+voidif_set_sockbuf(int);
 int if_set_mcast_loop(int);
 int if_set_ipv6_pktinfo(int, int);
 int if_set_ipv6_checksum(int);



Re: ospf6d: rename & move function

2019-12-22 Thread Sebastian Benoit
Denis Fondras(open...@ledeuns.net) on 2019.12.22 10:55:39 +0100:
> Rename and move calc_nexthop_clear()/calc_nexthop_add() to
> vertex_nexthop_clear()/vertex_nexthop_add()
> 
> It brings ospf6d closer to ospfd.

ok

> 
> 
> Index: rde.h
> ===
> RCS file: /cvs/src/usr.sbin/ospf6d/rde.h,v
> retrieving revision 1.22
> diff -u -p -r1.22 rde.h
> --- rde.h 1 Jul 2010 19:47:04 -   1.22
> +++ rde.h 18 Dec 2019 10:03:27 -
> @@ -140,6 +140,9 @@ void   orig_intra_area_prefix_lsas(struc
>  void  lsa_init(struct lsa_tree *);
>  int   lsa_compare(struct vertex *, struct vertex *);
>  void  vertex_free(struct vertex *);
> +void  vertex_nexthop_clear(struct vertex *);
> +void  vertex_nexthop_add(struct vertex *, struct vertex *,
> + const struct in6_addr *, u_int32_t);
>  int   lsa_newer(struct lsa_hdr *, struct lsa_hdr *);
>  int   lsa_check(struct rde_nbr *, struct lsa *, u_int16_t);
>  int   lsa_self(struct lsa *);
> Index: rde_lsdb.c
> ===
> RCS file: /cvs/src/usr.sbin/ospf6d/rde_lsdb.c,v
> retrieving revision 1.38
> diff -u -p -r1.38 rde_lsdb.c
> --- rde_lsdb.c18 Oct 2013 11:16:52 -  1.38
> +++ rde_lsdb.c18 Dec 2019 10:03:27 -
> @@ -99,9 +99,39 @@ void
>  vertex_free(struct vertex *v)
>  {
>   RB_REMOVE(lsa_tree, v->lsa_tree, v);
> +
>   (void)evtimer_del(>ev);
> + vertex_nexthop_clear(v);
>   free(v->lsa);
>   free(v);
> +}
> +
> +void
> +vertex_nexthop_clear(struct vertex *v)
> +{
> + struct v_nexthop*vn;
> +
> + while ((vn = TAILQ_FIRST(>nexthop))) {
> + TAILQ_REMOVE(>nexthop, vn, entry);
> + free(vn);
> + }
> +}
> +
> +void
> +vertex_nexthop_add(struct vertex *dst, struct vertex *parent,
> +const struct in6_addr *nexthop, u_int32_t ifindex)
> +{
> + struct v_nexthop*vn;
> +
> + if ((vn = calloc(1, sizeof(*vn))) == NULL)
> + fatal("vertex_nexthop_add");
> +
> + vn->prev = parent;
> + if (nexthop)
> + vn->nexthop = *nexthop;
> + vn->ifindex = ifindex;
> +
> + TAILQ_INSERT_TAIL(>nexthop, vn, entry);
>  }
>  
>  /* returns -1 if a is older, 1 if newer and 0 if equal to b */
> Index: rde_spf.c
> ===
> RCS file: /cvs/src/usr.sbin/ospf6d/rde_spf.c,v
> retrieving revision 1.25
> diff -u -p -r1.25 rde_spf.c
> --- rde_spf.c 5 Dec 2015 06:45:19 -   1.25
> +++ rde_spf.c 18 Dec 2019 10:03:27 -
> @@ -36,9 +36,6 @@ RB_PROTOTYPE(rt_tree, rt_node, entry, rt
>  RB_GENERATE(rt_tree, rt_node, entry, rt_compare)
>  struct vertex*spf_root = NULL;
>  
> -void  calc_nexthop_clear(struct vertex *);
> -void  calc_nexthop_add(struct vertex *, struct vertex *,
> -  const struct in6_addr *, u_int32_t);
>  struct in6_addr  *calc_nexthop_lladdr(struct vertex *, struct 
> lsa_rtr_link *,
>unsigned int);
>  void  calc_nexthop_transit_nbr(struct vertex *, struct vertex *,
> @@ -142,7 +139,7 @@ spf_calc(struct area *area)
>   continue;
>   if (d < w->cost) {
>   w->cost = d;
> - calc_nexthop_clear(w);
> + vertex_nexthop_clear(w);
>   calc_nexthop(w, v, area, rtr_link);
>   /*
>* need to readd to candidate list
> @@ -156,7 +153,7 @@ spf_calc(struct area *area)
>   } else if (w->cost == LS_INFINITY && d < LS_INFINITY) {
>   w->cost = d;
>  
> - calc_nexthop_clear(w);
> + vertex_nexthop_clear(w);
>   calc_nexthop(w, v, area, rtr_link);
>   cand_list_add(w);
>   }
> @@ -420,26 +417,25 @@ asext_calc(struct vertex *v)
>   }
>  
>   area.s_addr = 0;
> - calc_nexthop_clear(v);
> + vertex_nexthop_clear(v);
>   TAILQ_FOREACH(rn, >nexthop, entry) {
>   if (rn->invalid)
>   continue;
>  
>   if (rn->connected && r->d_type == DT_NET) {
>   if (metric & LSA_ASEXT_F_FLAG)
> - calc_nexthop_add(v, NULL, _addr,
> + vertex_nexthop_add(v, NULL, _addr,
>   rn->ifindex);
>   else
>   fatalx("asext_calc: I'm sorry Dave, "
> 

Re: ospf6d: rename & move function

2019-12-22 Thread Claudio Jeker
On Sun, Dec 22, 2019 at 10:55:39AM +0100, Denis Fondras wrote:
> Rename and move calc_nexthop_clear()/calc_nexthop_add() to
> vertex_nexthop_clear()/vertex_nexthop_add()
> 
> It brings ospf6d closer to ospfd.
> 

OK claudio@

> 
> Index: rde.h
> ===
> RCS file: /cvs/src/usr.sbin/ospf6d/rde.h,v
> retrieving revision 1.22
> diff -u -p -r1.22 rde.h
> --- rde.h 1 Jul 2010 19:47:04 -   1.22
> +++ rde.h 18 Dec 2019 10:03:27 -
> @@ -140,6 +140,9 @@ void   orig_intra_area_prefix_lsas(struc
>  void  lsa_init(struct lsa_tree *);
>  int   lsa_compare(struct vertex *, struct vertex *);
>  void  vertex_free(struct vertex *);
> +void  vertex_nexthop_clear(struct vertex *);
> +void  vertex_nexthop_add(struct vertex *, struct vertex *,
> + const struct in6_addr *, u_int32_t);
>  int   lsa_newer(struct lsa_hdr *, struct lsa_hdr *);
>  int   lsa_check(struct rde_nbr *, struct lsa *, u_int16_t);
>  int   lsa_self(struct lsa *);
> Index: rde_lsdb.c
> ===
> RCS file: /cvs/src/usr.sbin/ospf6d/rde_lsdb.c,v
> retrieving revision 1.38
> diff -u -p -r1.38 rde_lsdb.c
> --- rde_lsdb.c18 Oct 2013 11:16:52 -  1.38
> +++ rde_lsdb.c18 Dec 2019 10:03:27 -
> @@ -99,9 +99,39 @@ void
>  vertex_free(struct vertex *v)
>  {
>   RB_REMOVE(lsa_tree, v->lsa_tree, v);
> +
>   (void)evtimer_del(>ev);
> + vertex_nexthop_clear(v);
>   free(v->lsa);
>   free(v);
> +}
> +
> +void
> +vertex_nexthop_clear(struct vertex *v)
> +{
> + struct v_nexthop*vn;
> +
> + while ((vn = TAILQ_FIRST(>nexthop))) {
> + TAILQ_REMOVE(>nexthop, vn, entry);
> + free(vn);
> + }
> +}
> +
> +void
> +vertex_nexthop_add(struct vertex *dst, struct vertex *parent,
> +const struct in6_addr *nexthop, u_int32_t ifindex)
> +{
> + struct v_nexthop*vn;
> +
> + if ((vn = calloc(1, sizeof(*vn))) == NULL)
> + fatal("vertex_nexthop_add");
> +
> + vn->prev = parent;
> + if (nexthop)
> + vn->nexthop = *nexthop;
> + vn->ifindex = ifindex;
> +
> + TAILQ_INSERT_TAIL(>nexthop, vn, entry);
>  }
>  
>  /* returns -1 if a is older, 1 if newer and 0 if equal to b */
> Index: rde_spf.c
> ===
> RCS file: /cvs/src/usr.sbin/ospf6d/rde_spf.c,v
> retrieving revision 1.25
> diff -u -p -r1.25 rde_spf.c
> --- rde_spf.c 5 Dec 2015 06:45:19 -   1.25
> +++ rde_spf.c 18 Dec 2019 10:03:27 -
> @@ -36,9 +36,6 @@ RB_PROTOTYPE(rt_tree, rt_node, entry, rt
>  RB_GENERATE(rt_tree, rt_node, entry, rt_compare)
>  struct vertex*spf_root = NULL;
>  
> -void  calc_nexthop_clear(struct vertex *);
> -void  calc_nexthop_add(struct vertex *, struct vertex *,
> -  const struct in6_addr *, u_int32_t);
>  struct in6_addr  *calc_nexthop_lladdr(struct vertex *, struct 
> lsa_rtr_link *,
>unsigned int);
>  void  calc_nexthop_transit_nbr(struct vertex *, struct vertex *,
> @@ -142,7 +139,7 @@ spf_calc(struct area *area)
>   continue;
>   if (d < w->cost) {
>   w->cost = d;
> - calc_nexthop_clear(w);
> + vertex_nexthop_clear(w);
>   calc_nexthop(w, v, area, rtr_link);
>   /*
>* need to readd to candidate list
> @@ -156,7 +153,7 @@ spf_calc(struct area *area)
>   } else if (w->cost == LS_INFINITY && d < LS_INFINITY) {
>   w->cost = d;
>  
> - calc_nexthop_clear(w);
> + vertex_nexthop_clear(w);
>   calc_nexthop(w, v, area, rtr_link);
>   cand_list_add(w);
>   }
> @@ -420,26 +417,25 @@ asext_calc(struct vertex *v)
>   }
>  
>   area.s_addr = 0;
> - calc_nexthop_clear(v);
> + vertex_nexthop_clear(v);
>   TAILQ_FOREACH(rn, >nexthop, entry) {
>   if (rn->invalid)
>   continue;
>  
>   if (rn->connected && r->d_type == DT_NET) {
>   if (metric & LSA_ASEXT_F_FLAG)
> - calc_nexthop_add(v, NULL, _addr,
> + vertex_nexthop_add(v, NULL, _addr,
>   rn->ifindex);
>   else
>   fatalx("asext_calc: I'm sorry Dave, "
>  

ospf6d: rename & move function

2019-12-22 Thread Denis Fondras
Rename and move calc_nexthop_clear()/calc_nexthop_add() to
vertex_nexthop_clear()/vertex_nexthop_add()

It brings ospf6d closer to ospfd.


Index: rde.h
===
RCS file: /cvs/src/usr.sbin/ospf6d/rde.h,v
retrieving revision 1.22
diff -u -p -r1.22 rde.h
--- rde.h   1 Jul 2010 19:47:04 -   1.22
+++ rde.h   18 Dec 2019 10:03:27 -
@@ -140,6 +140,9 @@ void orig_intra_area_prefix_lsas(struc
 voidlsa_init(struct lsa_tree *);
 int lsa_compare(struct vertex *, struct vertex *);
 voidvertex_free(struct vertex *);
+voidvertex_nexthop_clear(struct vertex *);
+voidvertex_nexthop_add(struct vertex *, struct vertex *,
+   const struct in6_addr *, u_int32_t);
 int lsa_newer(struct lsa_hdr *, struct lsa_hdr *);
 int lsa_check(struct rde_nbr *, struct lsa *, u_int16_t);
 int lsa_self(struct lsa *);
Index: rde_lsdb.c
===
RCS file: /cvs/src/usr.sbin/ospf6d/rde_lsdb.c,v
retrieving revision 1.38
diff -u -p -r1.38 rde_lsdb.c
--- rde_lsdb.c  18 Oct 2013 11:16:52 -  1.38
+++ rde_lsdb.c  18 Dec 2019 10:03:27 -
@@ -99,9 +99,39 @@ void
 vertex_free(struct vertex *v)
 {
RB_REMOVE(lsa_tree, v->lsa_tree, v);
+
(void)evtimer_del(>ev);
+   vertex_nexthop_clear(v);
free(v->lsa);
free(v);
+}
+
+void
+vertex_nexthop_clear(struct vertex *v)
+{
+   struct v_nexthop*vn;
+
+   while ((vn = TAILQ_FIRST(>nexthop))) {
+   TAILQ_REMOVE(>nexthop, vn, entry);
+   free(vn);
+   }
+}
+
+void
+vertex_nexthop_add(struct vertex *dst, struct vertex *parent,
+const struct in6_addr *nexthop, u_int32_t ifindex)
+{
+   struct v_nexthop*vn;
+
+   if ((vn = calloc(1, sizeof(*vn))) == NULL)
+   fatal("vertex_nexthop_add");
+
+   vn->prev = parent;
+   if (nexthop)
+   vn->nexthop = *nexthop;
+   vn->ifindex = ifindex;
+
+   TAILQ_INSERT_TAIL(>nexthop, vn, entry);
 }
 
 /* returns -1 if a is older, 1 if newer and 0 if equal to b */
Index: rde_spf.c
===
RCS file: /cvs/src/usr.sbin/ospf6d/rde_spf.c,v
retrieving revision 1.25
diff -u -p -r1.25 rde_spf.c
--- rde_spf.c   5 Dec 2015 06:45:19 -   1.25
+++ rde_spf.c   18 Dec 2019 10:03:27 -
@@ -36,9 +36,6 @@ RB_PROTOTYPE(rt_tree, rt_node, entry, rt
 RB_GENERATE(rt_tree, rt_node, entry, rt_compare)
 struct vertex  *spf_root = NULL;
 
-voidcalc_nexthop_clear(struct vertex *);
-voidcalc_nexthop_add(struct vertex *, struct vertex *,
-const struct in6_addr *, u_int32_t);
 struct in6_addr*calc_nexthop_lladdr(struct vertex *, struct 
lsa_rtr_link *,
 unsigned int);
 voidcalc_nexthop_transit_nbr(struct vertex *, struct vertex *,
@@ -142,7 +139,7 @@ spf_calc(struct area *area)
continue;
if (d < w->cost) {
w->cost = d;
-   calc_nexthop_clear(w);
+   vertex_nexthop_clear(w);
calc_nexthop(w, v, area, rtr_link);
/*
 * need to readd to candidate list
@@ -156,7 +153,7 @@ spf_calc(struct area *area)
} else if (w->cost == LS_INFINITY && d < LS_INFINITY) {
w->cost = d;
 
-   calc_nexthop_clear(w);
+   vertex_nexthop_clear(w);
calc_nexthop(w, v, area, rtr_link);
cand_list_add(w);
}
@@ -420,26 +417,25 @@ asext_calc(struct vertex *v)
}
 
area.s_addr = 0;
-   calc_nexthop_clear(v);
+   vertex_nexthop_clear(v);
TAILQ_FOREACH(rn, >nexthop, entry) {
if (rn->invalid)
continue;
 
if (rn->connected && r->d_type == DT_NET) {
if (metric & LSA_ASEXT_F_FLAG)
-   calc_nexthop_add(v, NULL, _addr,
+   vertex_nexthop_add(v, NULL, _addr,
rn->ifindex);
else
fatalx("asext_calc: I'm sorry Dave, "
"I'm afraid I can't do that.");
} else
-   calc_nexthop_add(v, NULL, >nexthop,
+