From bd2b9f529383286ef480db797b58a1079eb3c023 Mon Sep 17 00:00:00 2001 From: claudio Date: Thu, 18 Jan 2024 11:03:16 +0000 Subject: [PATCH] Move the rtable_exists() check into in_pcbset_rtableid(). OK bluhm@ mvs@ --- sys/netinet/in_pcb.c | 6 +++++- sys/netinet/ip_output.c | 7 +------ sys/netinet6/ip6_output.c | 7 +------ 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c index 5ac1e8d0a89..41a9dfbaf2c 100644 --- a/sys/netinet/in_pcb.c +++ b/sys/netinet/in_pcb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in_pcb.c,v 1.284 2024/01/09 19:57:00 bluhm Exp $ */ +/* $OpenBSD: in_pcb.c,v 1.285 2024/01/18 11:03:16 claudio Exp $ */ /* $NetBSD: in_pcb.c,v 1.25 1996/02/13 23:41:53 christos Exp $ */ /* @@ -1306,6 +1306,10 @@ in_pcbset_rtableid(struct inpcb *inp, u_int rtableid) { struct inpcbtable *table = inp->inp_table; + /* table must exist */ + if (!rtable_exists(rtableid)) + return (EINVAL); + mtx_enter(&table->inpt_mtx); if (inp->inp_lport) { mtx_leave(&table->inpt_mtx); diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c index 87cf83c8171..761d063dc21 100644 --- a/sys/netinet/ip_output.c +++ b/sys/netinet/ip_output.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_output.c,v 1.392 2023/12/01 15:30:47 bluhm Exp $ */ +/* $OpenBSD: ip_output.c,v 1.393 2024/01/18 11:03:16 claudio Exp $ */ /* $NetBSD: ip_output.c,v 1.28 1996/02/13 23:43:07 christos Exp $ */ /* @@ -1077,11 +1077,6 @@ ip_ctloutput(int op, struct socket *so, int level, int optname, if (rtableid != rtid && rtableid != 0 && (error = suser(p)) != 0) break; - /* table must exist */ - if (!rtable_exists(rtid)) { - error = EINVAL; - break; - } error = in_pcbset_rtableid(inp, rtid); break; case IP_PIPEX: diff --git a/sys/netinet6/ip6_output.c b/sys/netinet6/ip6_output.c index 8366d833cf2..370f15fef40 100644 --- a/sys/netinet6/ip6_output.c +++ b/sys/netinet6/ip6_output.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip6_output.c,v 1.282 2023/12/01 15:30:47 bluhm Exp $ */ +/* $OpenBSD: ip6_output.c,v 1.283 2024/01/18 11:03:16 claudio Exp $ */ /* $KAME: ip6_output.c,v 1.172 2001/03/25 09:55:56 itojun Exp $ */ /* @@ -1376,11 +1376,6 @@ do { \ if (rtableid != rtid && rtableid != 0 && (error = suser(p)) != 0) break; - /* table must exist */ - if (!rtable_exists(rtid)) { - error = EINVAL; - break; - } error = in_pcbset_rtableid(inp, rtid); break; case IPV6_PIPEX: -- 2.20.1