]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[ipv6] Use driver-private data to hold link-local IPv6 settings block
authorMichael Brown <mcb30@ipxe.org>
Wed, 13 Sep 2023 21:21:08 +0000 (22:21 +0100)
committerMichael Brown <mcb30@ipxe.org>
Wed, 13 Sep 2023 22:02:54 +0000 (23:02 +0100)
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>
src/net/ipv6.c

index a0173dfb1df1e184491ce9e0c1d09f8ffeb6e307..8ee0804d3c22a0b68292f42cd97f566aef25eed5 100644 (file)
@@ -1212,14 +1212,6 @@ static struct settings_operations ipv6_settings_operations = {
        .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
  *
@@ -1227,37 +1219,26 @@ struct ipv6_settings {
  * @v priv             Private data
  * @ret rc             Return status code
  */
-static int ipv6_register_settings ( struct net_device *netdev,
-                                   void *priv __unused ) {
+static int ipv6_register_settings ( struct net_device *netdev, void *priv ) {
        struct settings *parent = netdev_settings ( netdev );
-       struct ipv6_settings *ipv6set;
+       struct settings *settings = priv;
        int rc;
 
-       /* Allocate and initialise structure */
-       ipv6set = zalloc ( sizeof ( *ipv6set ) );
-       if ( ! ipv6set ) {
-               rc = -ENOMEM;
-               goto err_alloc;
-       }
-       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,
+       /* Initialise and register settings */
+       settings_init ( settings, &ipv6_settings_operations,
+                       &netdev->refcnt, &ipv6_settings_scope );
+       settings->order = IPV6_ORDER_LINK_LOCAL;
+       if ( ( rc = register_settings ( settings, parent,
                                        IPV6_SETTINGS_NAME ) ) != 0 )
-               goto err_register;
+               return rc;
 
- err_register:
-       ref_put ( &ipv6set->refcnt );
- err_alloc:
-       return rc;
+       return 0;
 }
 
 /** IPv6 network device driver */
 struct net_driver ipv6_driver __net_driver = {
        .name = "IPv6",
+       .priv_len = sizeof ( struct settings ),
        .probe = ipv6_register_settings,
 };