Re: [systemd-devel] Mobile broadband modems support in systemd-networkd

2021-08-20 Thread Bruce A. Johnson
Mantas' and Ulrich's responses gave me insights to dig more. Neither the 
mbim-cli nor ModemManager sets the IP address on the interface, and some 
kind of agent needs to do that.


When I start the connection using ModemManager, I am able to retrieve 
addresses that mmcli displays like the below. If I manually assign the 
IPv4 address to the interface and set up the route, I'm able to send 
traffic to and from other nodes. I haven't yet looked into how 
ModemManager communicates this info to NetworkManager or how things like 
a change of address are handled. As I see it, these addresses aren't 
really static, because the IPv6 addresses are different from one mobile 
session to the next.




  IPv4 configuration | method: static
 |    address: 6.147.139.XXX
 | prefix: 30
 |    gateway: 6.147.139.YYY
 |    dns: 10.177.0.34, 10.177.0.210
 |    mtu: 1500
  
  IPv6 configuration | method: static
 |    address: 2607:fb90:648f:2648:a5b3:8146:95aa:2955
 | prefix: 64
 |    gateway: 2607:fb90:648f:2648:68d8:1c67:a27:b968
 |    dns: fd00:976a::9, fd00:976a::10
 |    mtu: 1500
  
I took a closer look at what's going on with systemd-networkd, and I 
found whether I use ModemManager or mbim-cli to connect to the mobile 
network, the .network file will be processed, but _only after I restart 
systemd-networkd_. When it is processed, the only address the interface 
gets is an IPv6 address, and it doesn't match the one in the 
ModemManager message above. I'm guessing that T-Mobile isn't providing 
DHCP for IPv4, and probably with good reason.



 [root@url-000db95362a6:~]# ip addr show wwan0
6: wwan0:  mtu 1500 qdisc 
pfifo_fast state UNKNOWN group default qlen 1000

    link/ether 52:95:20:b7:93:0f brd ff:ff:ff:ff:ff:ff
    inet6 2607:fb90:648f:2648:5095:20ff:feb7:930f/64 scope global 
mngtmpaddr noprefixroute

   valid_lft forever preferred_lft forever
    inet6 fe80::5095:20ff:feb7:930f/64 scope link
   valid_lft forever preferred_lft forever
[root@url-000db95362a6:~]# ip -6 route
::1 dev lo proto kernel metric 256 pref medium
2607:fb90:648f:2648::/64 dev wwan0 proto ra metric 1024 pref medium
fe80::/64 dev wwan0 proto kernel metric 256 pref medium
ff00::/8 dev wwan0 metric 256 pref medium
default via fe80::68d8:1c67:a27:b968 dev wwan0 proto ra metric 1024 
expires 65524sec mtu 1500 pref medium
At this point, I have a usable IP(v6) connection managed by 
systemd-networkd, but I can't see any indication that I'm getting DNS 
information. This could be that the only DNS tools I know of on my box 
are nslookup from Busybox and the gethostbyname() call in Python. Both 
are returning ESRCH.


My .network file for the interface looks like this:


[Match]
Name=wwan0

[Network]
Description=WAN connection on wwan0
DHCP=yes
IPv6AcceptRA=true

[DHCP]
UseDNS=yes
UseNTP=no
SendHostname=no
RouteMetric=0

[IPv6AcceptRA]
UseDNS=true
Is there something more that I need to add to get DNS addresses via the 
IPv6 router solicitation/advertisement mechanism, or does it appear that 
T-Mobile isn't providing DNS addresses except via the klunky method 
exposed by ModemManager?


Bruce A. Johnson | Firmware Engineer
Blue Ridge Networks, Inc.
14120 Parke Long Court Suite 103 | Chantilly, VA 20151
Main: 1.800.722.1168 | Direct: 703-633-7332
http://www.blueridgenetworks.com
OpenPGP key ID: 296D1CD6F2B84CABhttps://keys.openpgp.org/


On 20/08/2021 03:15, Ulrich Windl wrote:
Isn't the trick that the WIFI driver or kernel doe most of the magic 
required to make WIFI work, while a modem driver typically does not 
know much about the modem, i.e. a cellular modem requires some 
"special treatment".

Dumb question: Does it work without systemd (i.e..: Do yoiu hgave some code 
that does all that handling)?


On 20/08/2021 05:51, Mantas Mikulėnas wrote:


Wouldn't e.g. `mbimcli` configure IP on its own?


OpenPGP_signature
Description: OpenPGP digital signature


Re: [systemd-devel] How does journald talks to other services?

2021-08-20 Thread Mantas Mikulėnas
On Fri, Aug 20, 2021 at 2:11 PM Mantas Mikulėnas  wrote:

> On Fri, Aug 20, 2021 at 2:10 PM Nishant Nayan 
> wrote:
>
>> Regarding the below point :
>> c) The service prints to stdout/stderr, but systemd attaches the
>> service's stdout/stderr to a pipe which is read by journald (using
>> sd_journal_stream_fd(3) from libsystemd). See [Service] StandardOutput= in
>> systemd.service(5).
>>
>> I did not see StandardOutput field in [Service] sections of a service
>> file, for example sshd.service, but its logs are visible in journalctl.
>> Is it by default piped to journal and we need to explicitly mention it
>> (StandardOutput=)  only when we want to redirect it somewhere else?
>>
>
> StandardOutput=journal is the default setting.
>

And, actually, sshd doesn't write its messages to stdout anyway – it uses
syslog() via /dev/log; most daemons do.

-- 
Mantas Mikulėnas


Re: [systemd-devel] How does journald talks to other services?

2021-08-20 Thread Mantas Mikulėnas
On Fri, Aug 20, 2021 at 2:10 PM Nishant Nayan 
wrote:

> Regarding the below point :
> c) The service prints to stdout/stderr, but systemd attaches the service's
> stdout/stderr to a pipe which is read by journald (using
> sd_journal_stream_fd(3) from libsystemd). See [Service] StandardOutput= in
> systemd.service(5).
>
> I did not see StandardOutput field in [Service] sections of a service
> file, for example sshd.service, but its logs are visible in journalctl.
> Is it by default piped to journal and we need to explicitly mention it
> (StandardOutput=)  only when we want to redirect it somewhere else?
>

StandardOutput=journal is the default setting.

-- 
Mantas Mikulėnas


Re: [systemd-devel] How does journald talks to other services?

2021-08-20 Thread Nishant Nayan
Regarding the below point :
c) The service prints to stdout/stderr, but systemd attaches the service's
stdout/stderr to a pipe which is read by journald (using
sd_journal_stream_fd(3) from libsystemd). See [Service] StandardOutput= in
systemd.service(5).

I did not see StandardOutput field in [Service] sections of a service file,
for example sshd.service, but its logs are visible in journalctl.
Is it by default piped to journal and we need to explicitly mention it
(StandardOutput=)  only when we want to redirect it somewhere else?

Even in my self made service I did not mention StandardOutput=, but I can
see the logs in journalctl.

Is there a place where I can see .service file defaults ?

Nishant

On Fri, 20 Aug 2021 at 15:20, Mantas Mikulėnas  wrote:

> On Fri, Aug 20, 2021 at 12:31 PM Nishant Nayan <
> nayan.nishant2...@gmail.com> wrote:
>
>> Hi,
>> My query is how does systemd-journald talk to other services so that
>> it stores their logs/output in journal files, which could be displayed
>> using journalctl utlity.
>>
>
> Journald doesn't talk to services, services talk to journald:
>
> a) The service uses the standard syslog(3) call to send basic messages
> through the /dev/log socket, where journald (or a traditional syslogd) is
> listening.
>
> b) The service uses sd_journal_print(3) from libsystemd to send structured
> messages through /run/systemd/journal/socket (systemd-journald.socket).
> Some frameworks, such as GLib, have their own implementations of this
> protocol without needing libsystemd.
>
> c) The service prints to stdout/stderr, but systemd attaches the service's
> stdout/stderr to a pipe which is read by journald (using
> sd_journal_stream_fd(3) from libsystemd). See [Service] StandardOutput= in
> systemd.service(5).
>
> d) Journald also reads kernel messages (dmesg) from the /dev/kmsg device.
> Programs can actually write to /dev/kmsg to generate dmesg messages and
> journald will capture them.
>
> --
> Mantas Mikulėnas
>


Re: [systemd-devel] How does journald talks to other services?

2021-08-20 Thread Nishant Nayan
Thanks, I will check them out

Nishant

On Fri, 20 Aug 2021 at 15:22, Lennart Poettering 
wrote:

> On Fr, 20.08.21 15:01, Nishant Nayan (nayan.nishant2...@gmail.com) wrote:
>
> > Hi,
> > My query is how does systemd-journald talk to other services so that
> it
> > stores their logs/output in journal files, which could be displayed using
> > journalctl utlity.
> >   I am currently looking into systemd journal code to find this out but
> so
> > far no luck.
> >   Any suggestions would be appreciated.
>
> See docs:
>
> https://www.freedesktop.org/software/systemd/man/systemd-journald.service
>
> There's a list at the very beginning of the description there that
> lists the 5 different ways how log messages are delivered to journald.
>
> Lennart
>
> --
> Lennart Poettering, Berlin
>


Re: [systemd-devel] How does journald talks to other services?

2021-08-20 Thread Lennart Poettering
On Fr, 20.08.21 15:01, Nishant Nayan (nayan.nishant2...@gmail.com) wrote:

> Hi,
> My query is how does systemd-journald talk to other services so that it
> stores their logs/output in journal files, which could be displayed using
> journalctl utlity.
>   I am currently looking into systemd journal code to find this out but so
> far no luck.
>   Any suggestions would be appreciated.

See docs:

https://www.freedesktop.org/software/systemd/man/systemd-journald.service

There's a list at the very beginning of the description there that
lists the 5 different ways how log messages are delivered to journald.

Lennart

--
Lennart Poettering, Berlin


Re: [systemd-devel] Mobile broadband modems support in systemd-networkd

2021-08-20 Thread Mantas Mikulėnas
On Thu, Aug 19, 2021 at 10:46 PM Bruce A. Johnson <
bjohn...@blueridgenetworks.com> wrote:

> I am trying to integrate an MBIM cellular modem (Sierra Wireless MC7455)
> into my project, and while there seem to be plenty of people doing the
> same thing, all of the references seem to point to using ModemManager to
> set up the connection and NetworkManager to manage the IP config
> (address, gateway, and DNS). I'd like to avoid having to add
> NetworkManager to my build, since I've been getting along nicely with
> systemd-networkd for my Ethernet and Wi-Fi interfaces (using iwd to
> manage the Wi-Fi connection). Is there any work afoot to get
> systemd-networkd to set up the IP address info in concert with
> ModemManager, or do I have to force NetworkManager to play nicely with
> systemd-networkd?
>

Wouldn't e.g. `mbimcli` configure IP on its own?

-- 
Mantas Mikulėnas


Re: [systemd-devel] How does journald talks to other services?

2021-08-20 Thread Mantas Mikulėnas
On Fri, Aug 20, 2021 at 12:31 PM Nishant Nayan 
wrote:

> Hi,
> My query is how does systemd-journald talk to other services so that
> it stores their logs/output in journal files, which could be displayed
> using journalctl utlity.
>

Journald doesn't talk to services, services talk to journald:

a) The service uses the standard syslog(3) call to send basic messages
through the /dev/log socket, where journald (or a traditional syslogd) is
listening.

b) The service uses sd_journal_print(3) from libsystemd to send structured
messages through /run/systemd/journal/socket (systemd-journald.socket).
Some frameworks, such as GLib, have their own implementations of this
protocol without needing libsystemd.

c) The service prints to stdout/stderr, but systemd attaches the service's
stdout/stderr to a pipe which is read by journald (using
sd_journal_stream_fd(3) from libsystemd). See [Service] StandardOutput= in
systemd.service(5).

d) Journald also reads kernel messages (dmesg) from the /dev/kmsg device.
Programs can actually write to /dev/kmsg to generate dmesg messages and
journald will capture them.

-- 
Mantas Mikulėnas


[systemd-devel] How does journald talks to other services?

2021-08-20 Thread Nishant Nayan
Hi,
My query is how does systemd-journald talk to other services so that it
stores their logs/output in journal files, which could be displayed using
journalctl utlity.
  I am currently looking into systemd journal code to find this out but so
far no luck.
  Any suggestions would be appreciated.


Regards
Nishant


[systemd-devel] Antw: [EXT] [systemd‑devel] Mobile broadband modems support in systemd‑networkd

2021-08-20 Thread Ulrich Windl
>>> "Bruce A. Johnson"  schrieb am 19.08.2021 um
21:37 in Nachricht
<8926b5b1-6d52-cf73-8936-bb097d874...@blueridgenetworks.com>:
> I am trying to integrate an MBIM cellular modem (Sierra Wireless MC7455) 
> into my project, and while there seem to be plenty of people doing the 
> same thing, all of the references seem to point to using ModemManager to 
> set up the connection and NetworkManager to manage the IP config 
> (address, gateway, and DNS). I'd like to avoid having to add 
> NetworkManager to my build, since I've been getting along nicely with 
> systemd-networkd for my Ethernet and Wi-Fi interfaces (using iwd to 
> manage the Wi-Fi connection). Is there any work afoot to get 
> systemd-networkd to set up the IP address info in concert with 
> ModemManager, or do I have to force NetworkManager to play nicely with 
> systemd-networkd?

Isn't the trick that the WIFI driver or kernel doe most of the magic required 
to make WIFI work, while a modem driver typically does not know much about the 
modem, i.e. a cellular modem requires some "special treatment".

Dumb question: Does it work without systemd (i.e..: Do yoiu hgave some code 
that does all that handling)?

Regards,
Ulrich


> 
> -- 
> Bruce A. Johnson | Firmware Engineer
> Blue Ridge Networks, Inc.
> 14120 Parke Long Court Suite 103 | Chantilly, VA 20151
> Main: 1.800.722.1168 | Direct: 703-633-7332
> http://www.blueridgenetworks.com 
> OpenPGP key ID: 296D1CD6F2B84CAB https://keys.openpgp.org/