qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Samuel Thibault <samuel.thibault@gnu.org>
To: Peter Delevoryas <pdel@fb.com>
Cc: jasowang@redhat.com, eblake@redhat.com, armbru@redhat.com,
	qemu-devel@nongnu.org
Subject: Re: [PATCH 4/4] slirp: Add oob-eth-addr to -netdev options
Date: Sat, 18 Jun 2022 12:05:33 +0200	[thread overview]
Message-ID: <20220618100533.eb6frd5wu2hyfncu@begin> (raw)
In-Reply-To: <20220616010526.1895564-5-pdel@fb.com>

Peter Delevoryas, le mer. 15 juin 2022 18:05:26 -0700, a ecrit:
> With this change, you can now request the out-of-band MAC address from
> slirp in fby35-bmc:
> 
>     wget https://github.com/facebook/openbmc/releases/download/openbmc-e2294ff5d31d/fby35.mtd
>     qemu-system-arm -machine fby35-bmc \
>         -drive file=fby35.mtd,format=raw,if=mtd \
>         -nographic \
>         -netdev user,id=nic,mfr-id=0x8119,oob-eth-addr=de:ad:be:ef:ca:fe,hostfwd=::2222-:22 \
>         -net nic,model=ftgmac100,netdev=nic
> 
>     ...
>     username: root
>     password: 0penBmc
>     ...
> 
>     root@bmc-oob:~# ncsi-util -n eth0 -c 0 0x50 0 0 0x81 0x19 0 0 0x1b 0
>     NC-SI Command Response:
>     cmd: NCSI_OEM_CMD(0x50)
>     Response: COMMAND_COMPLETED(0x0000)  Reason: NO_ERROR(0x0000)
>     Payload length = 24
> 
>     20: 0x00 0x00 0x81 0x19
>     24: 0x01 0x00 0x1b 0x00
>     28: 0x00 0x00 0x00 0x00
>     32: 0xde 0xad 0xbe 0xef
>     36: 0xca 0xfe 0x00 0x00
> 
>     root@bmc-oob:~# ifconfig
>     eth0      Link encap:Ethernet  HWaddr DE:AD:BE:EF:CA:FE
> 	      inet addr:10.0.2.15  Bcast:10.0.2.255  Mask:255.255.255.0
> 	      inet6 addr: fec0::dcad:beff:feef:cafe/64 Scope:Site
> 	      inet6 addr: fe80::dcad:beff:feef:cafe/64 Scope:Link
> 	      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
> 	      RX packets:253 errors:0 dropped:0 overruns:0 frame:0
> 	      TX packets:271 errors:0 dropped:0 overruns:0 carrier:0
> 	      collisions:0 txqueuelen:1000
> 	      RX bytes:24638 (24.0 KiB)  TX bytes:18876 (18.4 KiB)
> 	      Interrupt:32
> 
>     lo        Link encap:Local Loopback
> 	      inet addr:127.0.0.1  Mask:255.0.0.0
> 	      inet6 addr: ::1/128 Scope:Host
> 	      UP LOOPBACK RUNNING  MTU:65536  Metric:1
> 	      RX packets:2 errors:0 dropped:0 overruns:0 frame:0
> 	      TX packets:2 errors:0 dropped:0 overruns:0 carrier:0
> 	      collisions:0 txqueuelen:1000
> 	      RX bytes:120 (120.0 B)  TX bytes:120 (120.0 B)
> 
> Signed-off-by: Peter Delevoryas <pdel@fb.com>
> ---
>  net/slirp.c   | 13 +++++++++++--
>  qapi/net.json |  5 ++++-
>  2 files changed, 15 insertions(+), 3 deletions(-)
> 
> diff --git a/net/slirp.c b/net/slirp.c
> index 231068c1e2..858d3da859 100644
> --- a/net/slirp.c
> +++ b/net/slirp.c
> @@ -414,7 +414,7 @@ static int net_slirp_init(NetClientState *peer, const char *model,
>                            const char *smb_export, const char *vsmbserver,
>                            const char **dnssearch, const char *vdomainname,
>                            const char *tftp_server_name, uint32_t mfr_id,
> -                          Error **errp)
> +                          uint8_t oob_eth_addr[ETH_ALEN], Error **errp)
>  {
>      /* default settings according to historic slirp */
>      struct in_addr net  = { .s_addr = htonl(0x0a000200) }; /* 10.0.2.0 */
> @@ -637,6 +637,7 @@ static int net_slirp_init(NetClientState *peer, const char *model,
>      cfg.vdnssearch = dnssearch;
>      cfg.vdomainname = vdomainname;
>      cfg.mfr_id = mfr_id;
> +    memcpy(cfg.oob_eth_addr, oob_eth_addr, ETH_ALEN);

And similarly here.

>      s->slirp = slirp_new(&cfg, &slirp_cb, s);
>      QTAILQ_INSERT_TAIL(&slirp_stacks, s, entry);
>  
> @@ -1142,6 +1143,7 @@ int net_init_slirp(const Netdev *netdev, const char *name,
>      const NetdevUserOptions *user;
>      const char **dnssearch;
>      bool ipv4 = true, ipv6 = true;
> +    MACAddr oob_eth_addr = {};
>  
>      assert(netdev->type == NET_CLIENT_DRIVER_USER);
>      user = &netdev->u.user;
> @@ -1166,6 +1168,12 @@ int net_init_slirp(const Netdev *netdev, const char *name,
>      net_init_slirp_configs(user->hostfwd, SLIRP_CFG_HOSTFWD);
>      net_init_slirp_configs(user->guestfwd, 0);
>  
> +    if (user->has_oob_eth_addr &&
> +        net_parse_macaddr(oob_eth_addr.a, user->oob_eth_addr) < 0) {
> +        error_setg(errp, "invalid syntax for OOB ethernet address");
> +        return -1;
> +    }
> +
>      ret = net_slirp_init(peer, "user", name, user->q_restrict,
>                           ipv4, vnet, user->host,
>                           ipv6, user->ipv6_prefix, user->ipv6_prefixlen,
> @@ -1173,7 +1181,8 @@ int net_init_slirp(const Netdev *netdev, const char *name,
>                           user->bootfile, user->dhcpstart,
>                           user->dns, user->ipv6_dns, user->smb,
>                           user->smbserver, dnssearch, user->domainname,
> -                         user->tftp_server_name, user->mfr_id, errp);
> +                         user->tftp_server_name, user->mfr_id, oob_eth_addr.a,
> +                         errp);
>  
>      while (slirp_configs) {
>          config = slirp_configs;
> diff --git a/qapi/net.json b/qapi/net.json
> index efc5cb3fb6..7b2c3c205c 100644
> --- a/qapi/net.json
> +++ b/qapi/net.json
> @@ -169,6 +169,8 @@
>  #
>  # @mfr-id: Manufacturer ID (Private Enterprise Number: IANA)
>  #
> +# @oob-eth-addr: Out-of-band ethernet address for BMC
> +#
>  # Since: 1.2
>  ##
>  { 'struct': 'NetdevUserOptions',
> @@ -195,7 +197,8 @@
>      '*hostfwd':   ['String'],
>      '*guestfwd':  ['String'],
>      '*tftp-server-name': 'str',
> -    '*mfr-id': 'uint32' } }
> +    '*mfr-id': 'uint32',
> +    '*oob-eth-addr': 'str' } }
>  
>  ##
>  # @NetdevTapOptions:
> -- 
> 2.30.2
> 

-- 
Samuel
---
Pour une évaluation indépendante, transparente et rigoureuse !
Je soutiens la Commission d'Évaluation de l'Inria.


  reply	other threads:[~2022-06-18 10:09 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-16  1:05 [PATCH 0/4] slirp: Update submodule to include NC-SI features Peter Delevoryas
2022-06-16  1:05 ` [PATCH 1/4] slirp: Update submodule to include NC-SI updates Peter Delevoryas
2022-06-16  1:05 ` [PATCH 2/4] slirp: Update SlirpConfig version to 5 Peter Delevoryas
2022-06-18 10:03   ` Samuel Thibault
2022-06-20 21:33     ` Peter Delevoryas
2022-06-16  1:05 ` [PATCH 3/4] slirp: Add mfr-id to -netdev options Peter Delevoryas
2022-06-18 10:05   ` Samuel Thibault
2022-06-20 22:58     ` Peter Delevoryas
2022-06-20  7:16   ` Markus Armbruster
2022-06-20 21:27     ` Peter Delevoryas
2022-06-21  9:01       ` Markus Armbruster
2022-06-16  1:05 ` [PATCH 4/4] slirp: Add oob-eth-addr " Peter Delevoryas
2022-06-18 10:05   ` Samuel Thibault [this message]
2022-06-20 23:01     ` Peter Delevoryas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220618100533.eb6frd5wu2hyfncu@begin \
    --to=samuel.thibault@gnu.org \
    --cc=armbru@redhat.com \
    --cc=eblake@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=pdel@fb.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).