After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 748131 - [review] some minor refactoring of platform [th/platform-div-bgo748131]
[review] some minor refactoring of platform [th/platform-div-bgo748131]
Status: RESOLVED FIXED
Product: NetworkManager
Classification: Platform
Component: general
git master
Other Linux
: Normal normal
: ---
Assigned To: NetworkManager maintainer(s)
NetworkManager maintainer(s)
Depends on:
Blocks: 747981
 
 
Reported: 2015-04-19 06:53 UTC by Thomas Haller
Modified: 2015-04-22 15:01 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Thomas Haller 2015-04-19 06:53:27 UTC
First parts from bug 747981.
Comment 1 Thomas Haller 2015-04-19 06:54:24 UTC
branch th/platform-div-bgo748131
Comment 2 Thomas Haller 2015-04-19 07:57:49 UTC
hm... this branch is broken.

I moved the initialization from nm-linux-platform.c:setup() to constructed().
The problem is, that all kind of code calls back into nm_platform functions, which crash due to missing singleton.


  • #0 __GI_raise
    at ../sysdeps/unix/sysv/linux/raise.c line 55
  • #1 __GI_abort
    at abort.c line 89
  • #2 g_assertion_message
  • #3 g_assertion_message_expr
    at gtestutils.c line 2307
  • #4 reset_error
    at ../nm-platform.c line 176
  • #5 nm_platform_tun_get_properties
    at ../nm-platform.c line 1339
  • #6 link_extract_type
    at ../nm-linux-platform.c line 994
  • #7 init_link
    at ../nm-linux-platform.c line 1042
  • #8 announce_object
    at ../nm-linux-platform.c line 1617
  • #9 udev_device_added
    at ../nm-linux-platform.c line 4459
  • #10 constructed
    at ../nm-linux-platform.c line 4620
  • #11 g_object_new_internal
    at gobject.c line 1814
  • #12 g_object_newv
    at gobject.c line 1922
  • #13 g_object_new
    at gobject.c line 1614
  • #14 nm_linux_platform_setup
    at ../nm-linux-platform.c line 573
  • #15 main
    at test-common.c line 286



A NMPlatform instance is only usable, if the singleton is initialized via nm_platform_setup(). I wish, NMPlatform would be useable without being a singleton. I see usecases for that, for example, we could have a NMPlatform instnce whose netlink socket is connected into another NET namespace.

I would like to modify function in nm-platform.h to accept a @self argument. For convenience, it could accept NULL, which means: use nm_platform_get() instead.


Would that be ok?
Comment 3 Thomas Haller 2015-04-20 11:45:05 UTC
-- on hold. First decide hot to proceed with @self argument to platform code.
Comment 4 Thomas Haller 2015-04-21 16:14:52 UTC
After merging [1], th/platform-div-bgo748131 is again up for review.

[1] http://cgit.freedesktop.org/NetworkManager/NetworkManager/commit/?id=c6529a9d748ad3c8ee37431d020a7b9223992a23
Comment 5 Dan Williams 2015-04-21 21:21:54 UTC
> platform: drop virtual setup() initalization function

I assume the "nm_fake_platform_setup2()" is a typo?

> platform: add _LOG() logging macros to linux platform

What's the point of defining _LOG_LEVEL_ENABLED as quasi-function?  eg, why couldn't it just be "#define _LOG_LEVEL_ENABLED nm_logging_enabled(...)"?

> platform: refactor detection of support_user_ipv6ll

I don't think we need the freeze_result parameter.  The only time 'FALSE' is used is from nm-device.c::constuctor(), and since this call requires a valid ifindex, there's no possible way we can create an NMDevice with a valid ifindex that *doesn't* come from the platform already, right?

Second, before nm_platform_link_get_user_ipv6ll_enabled() gets called, nm-device.c calls nm_platform_check_support_user_ipv6ll(), which itself calls _support_user_ipv6ll_get (TRUE) which freezes the value already.  So I think we can just always freeze the result?
Comment 6 Thomas Haller 2015-04-22 08:47:43 UTC
(In reply to Dan Williams from comment #5)
> > platform: drop virtual setup() initalization function
> 
> I assume the "nm_fake_platform_setup2()" is a typo?

reworded commit message.


> > platform: add _LOG() logging macros to linux platform
> 
> What's the point of defining _LOG_LEVEL_ENABLED as quasi-function?  eg, why
> couldn't it just be "#define _LOG_LEVEL_ENABLED nm_logging_enabled(...)"?

fixed, and a few further minor adjustments.


> > platform: refactor detection of support_user_ipv6ll
> 
> I don't think we need the freeze_result parameter.  The only time 'FALSE' is
> used is from nm-device.c::constuctor(), and since this call requires a valid
> ifindex, there's no possible way we can create an NMDevice with a valid
> ifindex that *doesn't* come from the platform already, right?
> 
> Second, before nm_platform_link_get_user_ipv6ll_enabled() gets called,
> nm-device.c calls nm_platform_check_support_user_ipv6ll(), which itself
> calls _support_user_ipv6ll_get (TRUE) which freezes the value already.  So I
> think we can just always freeze the result?

As you say, the situation probably never arises.

And even if it would happen, it would be very strange that support is first FALSE (unknown), and later gets detected. The functions should make up it's mind once and stick with it.

Changed.


Repushed with fixups.
Comment 7 Beniamino Galvani 2015-04-22 12:28:17 UTC
Apart from the nl/ipv6 parts I'm not very familiar with, the rest looks good to me.

>            nm_log ((__level), (__domain), \
>                    "%s: " _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \
>                    __p_prefix _NM_UTILS_MACRO_REST (__VA_ARGS__)); \

Just a minor improvement: __level and __domain aren't macro arguments and so the parenthesis aren't needed.
Comment 8 Thomas Haller 2015-04-22 12:49:36 UTC
(In reply to Beniamino Galvani from comment #7)
> Apart from the nl/ipv6 parts I'm not very familiar with, the rest looks good
> to me.
> 
> >            nm_log ((__level), (__domain), \
> >                    "%s: " _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \
> >                    __p_prefix _NM_UTILS_MACRO_REST (__VA_ARGS__)); \
> 
> Just a minor improvement: __level and __domain aren't macro arguments and so
> the parenthesis aren't needed.

fixed.
Comment 9 Thomas Haller 2015-04-22 15:01:09 UTC
IMO this branch is trivial enough.

I just went ahead and merged it:

http://cgit.freedesktop.org/NetworkManager/NetworkManager/commit/?id=2316d233e36d7c98e4ecad2016ed2467c853a6a0