[ipv6] Use driver-private data to hold link-local IPv6 settings block

Simplify the IPv6 link-local settings code by using driver-private
data to hold the settings block, instead of using a separate
allocation.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2023-09-13 22:21:08 +01:00
parent cc1e27e525
commit 8b1d34badf

View File

@@ -1212,14 +1212,6 @@ static struct settings_operations ipv6_settings_operations = {
.fetch = ipv6_fetch, .fetch = ipv6_fetch,
}; };
/** IPv6 link-local address settings */
struct ipv6_settings {
/** Reference counter */
struct refcnt refcnt;
/** Settings interface */
struct settings settings;
};
/** /**
* Register IPv6 link-local address settings * Register IPv6 link-local address settings
* *
@@ -1227,37 +1219,26 @@ struct ipv6_settings {
* @v priv Private data * @v priv Private data
* @ret rc Return status code * @ret rc Return status code
*/ */
static int ipv6_register_settings ( struct net_device *netdev, static int ipv6_register_settings ( struct net_device *netdev, void *priv ) {
void *priv __unused ) {
struct settings *parent = netdev_settings ( netdev ); struct settings *parent = netdev_settings ( netdev );
struct ipv6_settings *ipv6set; struct settings *settings = priv;
int rc; int rc;
/* Allocate and initialise structure */ /* Initialise and register settings */
ipv6set = zalloc ( sizeof ( *ipv6set ) ); settings_init ( settings, &ipv6_settings_operations,
if ( ! ipv6set ) { &netdev->refcnt, &ipv6_settings_scope );
rc = -ENOMEM; settings->order = IPV6_ORDER_LINK_LOCAL;
goto err_alloc; if ( ( rc = register_settings ( settings, parent,
}
ref_init ( &ipv6set->refcnt, NULL );
settings_init ( &ipv6set->settings, &ipv6_settings_operations,
&ipv6set->refcnt, &ipv6_settings_scope );
ipv6set->settings.order = IPV6_ORDER_LINK_LOCAL;
/* Register settings */
if ( ( rc = register_settings ( &ipv6set->settings, parent,
IPV6_SETTINGS_NAME ) ) != 0 ) IPV6_SETTINGS_NAME ) ) != 0 )
goto err_register; return rc;
err_register: return 0;
ref_put ( &ipv6set->refcnt );
err_alloc:
return rc;
} }
/** IPv6 network device driver */ /** IPv6 network device driver */
struct net_driver ipv6_driver __net_driver = { struct net_driver ipv6_driver __net_driver = {
.name = "IPv6", .name = "IPv6",
.priv_len = sizeof ( struct settings ),
.probe = ipv6_register_settings, .probe = ipv6_register_settings,
}; };