sync code with last fixes and improvements from OpenBSD

This commit is contained in:
purplerain 2023-05-14 12:20:04 +00:00
parent 62073e0295
commit 0f55503fed
Signed by: purplerain
GPG key ID: F42C07F07E2E35B7
72 changed files with 797 additions and 1127 deletions

View file

@ -640,7 +640,7 @@ bfd_upcall(struct socket *so, caddr_t arg, int waitflag)
struct bfd_config *bfd = (struct bfd_config *)arg;
bfd->bc_upcallso = so;
task_add(bfdtq, &bfd->bc_upcall_task);
task_add(bfdtq, &bfd->bc_upcall_task);
}
void

View file

@ -1,4 +1,4 @@
/* $OpenBSD: if.c,v 1.695 2023/05/07 16:23:23 bluhm Exp $ */
/* $OpenBSD: if.c,v 1.696 2023/05/14 01:46:53 dlg Exp $ */
/* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */
/*
@ -243,8 +243,13 @@ int ifq_congestion;
int netisr;
struct softnet {
char sn_name[16];
struct taskq *sn_taskq;
};
#define NET_TASKQ 4
struct taskq *nettqmp[NET_TASKQ];
struct softnet softnets[NET_TASKQ];
struct task if_input_task_locked = TASK_INITIALIZER(if_netisr, NULL);
@ -269,8 +274,11 @@ ifinit(void)
if_idxmap_init(8); /* 8 is a nice power of 2 for malloc */
for (i = 0; i < NET_TASKQ; i++) {
nettqmp[i] = taskq_create("softnet", 1, IPL_NET, TASKQ_MPSAFE);
if (nettqmp[i] == NULL)
struct softnet *sn = &softnets[i];
snprintf(sn->sn_name, sizeof(sn->sn_name), "softnet%u", i);
sn->sn_taskq = taskq_create(sn->sn_name, 1, IPL_NET,
TASKQ_MPSAFE);
if (sn->sn_taskq == NULL)
panic("unable to create network taskq %d", i);
}
}
@ -3463,13 +3471,13 @@ unhandled_af(int af)
struct taskq *
net_tq(unsigned int ifindex)
{
struct taskq *t = NULL;
struct softnet *sn;
static int nettaskqs;
if (nettaskqs == 0)
nettaskqs = min(NET_TASKQ, ncpus);
t = nettqmp[ifindex % nettaskqs];
sn = &softnets[ifindex % nettaskqs];
return (t);
return (sn->sn_taskq);
}

View file

@ -1,4 +1,4 @@
/* $OpenBSD: if_bridge.c,v 1.366 2023/05/07 16:23:23 bluhm Exp $ */
/* $OpenBSD: if_bridge.c,v 1.367 2023/05/13 13:35:17 bluhm Exp $ */
/*
* Copyright (c) 1999, 2000 Jason L. Wright (jason@thought.net)
@ -1735,15 +1735,8 @@ bridge_ip(struct ifnet *brifp, int dir, struct ifnet *ifp,
return (NULL);
if (m->m_len < sizeof(struct ip))
goto dropit;
in_hdr_cksum_out(m, ifp);
in_proto_cksum_out(m, ifp);
ip = mtod(m, struct ip *);
ip->ip_sum = 0;
if (0 && (ifp->if_capabilities & IFCAP_CSUM_IPv4))
m->m_pkthdr.csum_flags |= M_IPV4_CSUM_OUT;
else {
ipstat_inc(ips_outswcsum);
ip->ip_sum = in_cksum(m, hlen);
}
#if NPF > 0
if (dir == BRIDGE_IN &&
@ -1993,8 +1986,7 @@ bridge_send_icmp_err(struct ifnet *ifp,
ip->ip_off &= htons(IP_DF);
ip->ip_id = htons(ip_randomid());
ip->ip_ttl = MAXTTL;
ip->ip_sum = 0;
ip->ip_sum = in_cksum(m, hlen);
in_hdr_cksum_out(m, NULL);
/* Swap ethernet addresses */
bcopy(&eh->ether_dhost, &ether_tmp, sizeof(ether_tmp));

View file

@ -1,4 +1,4 @@
/* $OpenBSD: if_gre.c,v 1.173 2023/04/13 02:19:05 jsg Exp $ */
/* $OpenBSD: if_gre.c,v 1.174 2023/05/13 13:35:17 bluhm Exp $ */
/* $NetBSD: if_gre.c,v 1.9 1999/10/25 19:18:11 drochner Exp $ */
/*
@ -3028,8 +3028,7 @@ gre_keepalive_send(void *arg)
ip = mtod(m, struct ip *);
ip->ip_id = htons(ip_randomid());
ip->ip_sum = 0;
ip->ip_sum = in_cksum(m, sizeof(*ip));
in_hdr_cksum_out(m, NULL);
proto = htons(ETHERTYPE_IP);
break;

View file

@ -1,4 +1,4 @@
/* $OpenBSD: pf.c,v 1.1178 2023/05/10 12:07:16 bluhm Exp $ */
/* $OpenBSD: pf.c,v 1.1179 2023/05/13 13:35:17 bluhm Exp $ */
/*
* Copyright (c) 2001 Daniel Hartmeier
@ -2868,7 +2868,7 @@ pf_change_icmp_af(struct mbuf *m, int ipoff2, struct pf_pdesc *pd,
ip4->ip_p = pd2->proto;
ip4->ip_src = src->v4;
ip4->ip_dst = dst->v4;
ip4->ip_sum = in_cksum(n, ip4->ip_hl << 2);
in_hdr_cksum_out(n, NULL);
break;
case AF_INET6:
ip6 = mtod(n, struct ip6_hdr *);
@ -6549,13 +6549,7 @@ pf_route(struct pf_pdesc *pd, struct pf_state *st)
}
if (ntohs(ip->ip_len) <= ifp->if_mtu) {
ip->ip_sum = 0;
if (ifp->if_capabilities & IFCAP_CSUM_IPv4)
m0->m_pkthdr.csum_flags |= M_IPV4_CSUM_OUT;
else {
ipstat_inc(ips_outswcsum);
ip->ip_sum = in_cksum(m0, ip->ip_hl << 2);
}
in_hdr_cksum_out(m0, ifp);
in_proto_cksum_out(m0, ifp);
ifp->if_output(ifp, m0, sintosa(dst), rt);
goto done;