From owner-svn-src-head@freebsd.org Sun Jan 5 19:14:17 2020 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3C5BD1E323B; Sun, 5 Jan 2020 19:14:17 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47rSxP0v7Rz4dqj; Sun, 5 Jan 2020 19:14:17 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 18C5322A0; Sun, 5 Jan 2020 19:14:17 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 005JEGm1096462; Sun, 5 Jan 2020 19:14:16 GMT (envelope-from bz@FreeBSD.org) Received: (from bz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 005JEGl8096460; Sun, 5 Jan 2020 19:14:16 GMT (envelope-from bz@FreeBSD.org) Message-Id: <202001051914.005JEGl8096460@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bz set sender to bz@FreeBSD.org using -f From: "Bjoern A. Zeeb" Date: Sun, 5 Jan 2020 19:14:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r356386 - head/sys/netgraph X-SVN-Group: head X-SVN-Commit-Author: bz X-SVN-Commit-Paths: head/sys/netgraph X-SVN-Commit-Revision: 356386 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 05 Jan 2020 19:14:17 -0000 Author: bz Date: Sun Jan 5 19:14:16 2020 New Revision: 356386 URL: https://svnweb.freebsd.org/changeset/base/356386 Log: netgraph/ng_bridge: Reestablish old ABI In order to be able to merge r353026 bring back support for the old cookie API for a transition period in 12.x releases (and possibly 13) before the old API can be removed again entirely. Suggested by: julian Submitted by: Lutz Donnerhacke (lutz donnerhacke.de) PR: 240787 Reviewed by: julian MFC after: 2 weeks X-MFC with: r353026 Differential Revision: https://reviews.freebsd.org/D21961 Modified: head/sys/netgraph/ng_bridge.c head/sys/netgraph/ng_bridge.h Modified: head/sys/netgraph/ng_bridge.c ============================================================================== --- head/sys/netgraph/ng_bridge.c Sun Jan 5 18:15:41 2020 (r356385) +++ head/sys/netgraph/ng_bridge.c Sun Jan 5 19:14:16 2020 (r356386) @@ -393,6 +393,72 @@ ng_bridge_rcvmsg(node_p node, item_p item, hook_p last NGI_GET_MSG(item, msg); switch (msg->header.typecookie) { +#ifdef NGM_BRIDGE_TABLE_ABI + case NGM_BRIDGE_COOKIE_TBL: + switch (msg->header.cmd) { + case NGM_BRIDGE_GET_CONFIG: + { + struct ng_bridge_config_tbl *conf; + + NG_MKRESPONSE(resp, msg, sizeof(*conf), + M_NOWAIT|M_ZERO); + if (resp == NULL) { + error = ENOMEM; + break; + } + conf = (struct ng_bridge_config_tbl *)resp->data; + conf->cfg = priv->conf; + break; + } + case NGM_BRIDGE_SET_CONFIG: + { + struct ng_bridge_config_tbl *conf; + + if (msg->header.arglen != sizeof(*conf)) { + error = EINVAL; + break; + } + conf = (struct ng_bridge_config_tbl *)msg->data; + priv->conf = conf->cfg; + break; + } + case NGM_BRIDGE_GET_TABLE: + { + struct ng_bridge_host_tbl_ary *ary; + struct ng_bridge_hent *hent; + int i, bucket; + + NG_MKRESPONSE(resp, msg, sizeof(*ary) + + (priv->numHosts * sizeof(*ary->hosts)), M_NOWAIT); + if (resp == NULL) { + error = ENOMEM; + break; + } + ary = (struct ng_bridge_host_tbl_ary *)resp->data; + ary->numHosts = priv->numHosts; + i = 0; + for (bucket = 0; bucket < priv->numBuckets; bucket++) { + SLIST_FOREACH(hent, &priv->tab[bucket], next) { + memcpy(ary->hosts[i].addr, + hent->host.addr, + sizeof(ary->hosts[i].addr)); + ary->hosts[i].age = hent->host.age; + ary->hosts[i].staleness = + hent->host.staleness; + ary->hosts[i].linkNum = strtol( + NG_HOOK_NAME(hent->host.link->hook) + + strlen(NG_BRIDGE_HOOK_LINK_PREFIX), + NULL, 10); + i++; + } + } + break; + } + } + /* If already handled break, otherwise use new ABI. */ + if (resp != NULL || error != 0) + break; +#endif /* NGM_BRIDGE_TABLE_ABI */ case NGM_BRIDGE_COOKIE: switch (msg->header.cmd) { case NGM_BRIDGE_GET_CONFIG: Modified: head/sys/netgraph/ng_bridge.h ============================================================================== --- head/sys/netgraph/ng_bridge.h Sun Jan 5 18:15:41 2020 (r356385) +++ head/sys/netgraph/ng_bridge.h Sun Jan 5 19:14:16 2020 (r356386) @@ -43,10 +43,24 @@ #ifndef _NETGRAPH_NG_BRIDGE_H_ #define _NETGRAPH_NG_BRIDGE_H_ +/* + * Support the older ABI based on fixed size tables. + * ABI is deprecated, to be removed in releases > 12 + * Please note: There is no API support! + * You canno create new messages using the old API but messages conforming the + * old ABI are understood. + */ +#define NGM_BRIDGE_TABLE_ABI + /* Node type name and magic cookie */ #define NG_BRIDGE_NODE_TYPE "bridge" #define NGM_BRIDGE_COOKIE 1569321993 +#ifdef NGM_BRIDGE_TABLE_ABI +#define NGM_BRIDGE_COOKIE_TBL 967239368 +#define NG_BRIDGE_MAX_LINKS 32 +#endif /* NGM_BRIDGE_TABLE_ABI */ + /* Hook names */ #define NG_BRIDGE_HOOK_LINK_PREFIX "link" /* append decimal integer */ #define NG_BRIDGE_HOOK_LINK_FMT "link%d" /* for use with printf(3) */ @@ -59,6 +73,13 @@ struct ng_bridge_config { u_int32_t minStableAge; /* min time for a stable host */ }; +#ifdef NGM_BRIDGE_TABLE_ABI +struct ng_bridge_config_tbl { + u_char ipfw[NG_BRIDGE_MAX_LINKS]; + struct ng_bridge_config cfg; +}; +#endif /* NGM_BRIDGE_TABLE_ABI */ + /* Keep this in sync with the above structure definition */ #define NG_BRIDGE_CONFIG_TYPE_INFO { \ { "debugLevel", &ng_parse_uint8_type }, \ @@ -115,6 +136,15 @@ struct ng_bridge_host { u_int16_t staleness; /* seconds ago host last heard from */ }; +#ifdef NGM_BRIDGE_TABLE_ABI +struct ng_bridge_host_tbl { + u_char addr[6]; /* ethernet address */ + u_int16_t linkNum; /* link where addr can be found */ + u_int16_t age; /* seconds ago entry was created */ + u_int16_t staleness; /* seconds ago host last heard from */ +}; +#endif /* NGM_BRIDGE_TABLE_ABI */ + /* external representation of the host */ struct ng_bridge_hostent { u_char addr[6]; /* ethernet address */ @@ -144,6 +174,19 @@ struct ng_bridge_host_ary { { "hosts", (harytype) }, \ { NULL } \ } + +#ifdef NGM_BRIDGE_TABLE_ABI +struct ng_bridge_hostent_tbl { + u_char addr[6]; /* ethernet address */ + u_int16_t linkNum; /* link where addr can be found */ + u_int16_t age; /* seconds ago entry was created */ + u_int16_t staleness; /* seconds ago host last heard from */ +}; +struct ng_bridge_host_tbl_ary { + u_int32_t numHosts; + struct ng_bridge_hostent_tbl hosts[]; +}; +#endif /* NGM_BRIDGE_TABLE_ABI */ /* Netgraph control messages */ enum {