qemu-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-commits] [qemu/qemu] 831734: net: Fix handling of id in netdev_add


From: Peter Maydell
Subject: [Qemu-commits] [qemu/qemu] 831734: net: Fix handling of id in netdev_add and netdev_del
Date: Mon, 25 Jan 2021 08:01:54 -0800

  Branch: refs/heads/staging
  Home:   https://github.com/qemu/qemu
  Commit: 831734cce6494032e9233caff4d8442b3a1e7fef
      
https://github.com/qemu/qemu/commit/831734cce6494032e9233caff4d8442b3a1e7fef
  Author: Markus Armbruster <armbru@redhat.com>
  Date:   2021-01-25 (Mon, 25 Jan 2021)

  Changed paths:
    M net/net.c

  Log Message:
  -----------
  net: Fix handling of id in netdev_add and netdev_del

CLI -netdev accumulates in option group "netdev".

Before commit 08712fcb85 "net: Track netdevs in NetClientState rather
than QemuOpt", netdev_add added to the option group, and netdev_del
removed from it, both HMP and QMP.  Thus, every netdev had a
corresponding QemuOpts in this option group.

Commit 08712fcb85 dropped this for QMP netdev_add and both netdev_del.
Now a netdev has a corresponding QemuOpts only when it was created
with CLI or HMP.  Two issues:

* QMP and HMP netdev_del can leave QemuOpts behind, breaking HMP
  netdev_add.  Reproducer:

    $ qemu-system-x86_64 -S -display none -nodefaults -monitor stdio
    QEMU 5.1.92 monitor - type 'help' for more information
    (qemu) netdev_add user,id=net0
    (qemu) info network
    net0: index=0,type=user,net=10.0.2.0,restrict=off
    (qemu) netdev_del net0
    (qemu) info network
    (qemu) netdev_add user,id=net0
    upstream-qemu: Duplicate ID 'net0' for netdev
    Try "help netdev_add" for more information

  Fix by restoring the QemuOpts deletion in qmp_netdev_del(), but with
  a guard, because the QemuOpts need not exist.

* QMP netdev_add loses its "no duplicate ID" check.  Reproducer:

    $ qemu-system-x86_64 -S -display none -qmp stdio
    {"QMP": {"version": {"qemu": {"micro": 92, "minor": 1, "major": 5}, 
"package": "v5.2.0-rc2-1-g02c1f0142c"}, "capabilities": ["oob"]}}
    {"execute": "qmp_capabilities"}
    {"return": {}}
    {"execute": "netdev_add", "arguments": {"type": "user", "id":"net0"}}
    {"return": {}}
    {"execute": "netdev_add", "arguments": {"type": "user", "id":"net0"}}
    {"return": {}}

  Fix by adding a duplicate ID check to net_client_init1() to replace
  the lost one.  The check is redundant for callers where QemuOpts
  still checks, i.e. for CLI and HMP.

Reported-by: Andrew Melnichenko <andrew@daynix.com>
Fixes: 08712fcb851034228b61f75bd922863a984a4f60
Cc: qemu-stable@nongnu.org
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>


  Commit: 0dcf0c0aeefd2bc1023c9fe7ab0f1b6bc993c360
      
https://github.com/qemu/qemu/commit/0dcf0c0aeefd2bc1023c9fe7ab0f1b6bc993c360
  Author: Markus Carlstedt <markus.carlstedt@windriver.com>
  Date:   2021-01-25 (Mon, 25 Jan 2021)

  Changed paths:
    M net/checksum.c

  Log Message:
  -----------
  net: checksum: Skip fragmented IP packets

To calculate the TCP/UDP checksum we need the whole datagram. Unless
the hardware has some logic to collect all fragments before sending
the whole datagram first, it can only be done by the network stack,
which is normally the case for the NICs we have seen so far.

Skip these fragmented IP packets to avoid checksum corruption.

Signed-off-by: Markus Carlstedt <markus.carlstedt@windriver.com>
Signed-off-by: Bin Meng <bin.meng@windriver.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>


  Commit: d97f11590a0f60cd911ace8bb68180b5a09a068d
      
https://github.com/qemu/qemu/commit/d97f11590a0f60cd911ace8bb68180b5a09a068d
  Author: Guishan Qin <guishan.qin@windriver.com>
  Date:   2021-01-25 (Mon, 25 Jan 2021)

  Changed paths:
    M net/checksum.c

  Log Message:
  -----------
  net: checksum: Add IP header checksum calculation

At present net_checksum_calculate() only calculates TCP/UDP checksum
in an IP packet, but assumes the IP header checksum to be provided
by the software, e.g.: Linux kernel always calculates the IP header
checksum. However this might not always be the case, e.g.: for an IP
checksum offload enabled stack like VxWorks, the IP header checksum
can be zero.

This adds the checksum calculation of the IP header.

Signed-off-by: Guishan Qin <guishan.qin@windriver.com>
Signed-off-by: Yabing Liu <yabing.liu@windriver.com>
Signed-off-by: Bin Meng <bin.meng@windriver.com>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Signed-off-by: Jason Wang <jasowang@redhat.com>


  Commit: f574633529926697ced51b6865e5c50bbb78bf1b
      
https://github.com/qemu/qemu/commit/f574633529926697ced51b6865e5c50bbb78bf1b
  Author: Bin Meng <bin.meng@windriver.com>
  Date:   2021-01-25 (Mon, 25 Jan 2021)

  Changed paths:
    M hw/net/allwinner-sun8i-emac.c
    M hw/net/cadence_gem.c
    M hw/net/fsl_etsec/rings.c
    M hw/net/ftgmac100.c
    M hw/net/imx_fec.c
    M hw/net/virtio-net.c
    M hw/net/xen_nic.c
    M include/net/checksum.h
    M net/checksum.c
    M net/filter-rewriter.c

  Log Message:
  -----------
  net: checksum: Introduce fine control over checksum type

At present net_checksum_calculate() blindly calculates all types of
checksums (IP, TCP, UDP). Some NICs may have a per type setting in
their BDs to control what checksum should be offloaded. To support
such hardware behavior, introduce a 'csum_flag' parameter to the
net_checksum_calculate() API to allow fine control over what type
checksum is calculated.

Existing users of this API are updated accordingly.

Signed-off-by: Bin Meng <bin.meng@windriver.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>


  Commit: 31ee895047bdcf7387e3570cbd2a473c6f744b08
      
https://github.com/qemu/qemu/commit/31ee895047bdcf7387e3570cbd2a473c6f744b08
  Author: Peter Maydell <peter.maydell@linaro.org>
  Date:   2021-01-25 (Mon, 25 Jan 2021)

  Changed paths:
    M hw/net/allwinner-sun8i-emac.c
    M hw/net/cadence_gem.c
    M hw/net/fsl_etsec/rings.c
    M hw/net/ftgmac100.c
    M hw/net/imx_fec.c
    M hw/net/virtio-net.c
    M hw/net/xen_nic.c
    M include/net/checksum.h
    M net/checksum.c
    M net/filter-rewriter.c
    M net/net.c

  Log Message:
  -----------
  Merge remote-tracking branch 'remotes/jasowang/tags/net-pull-request' into 
staging

# gpg: Signature made Mon 25 Jan 2021 09:05:51 GMT
# gpg:                using RSA key EF04965B398D6211
# gpg: Good signature from "Jason Wang (Jason Wang on RedHat) 
<jasowang@redhat.com>" [marginal]
# gpg: WARNING: This key is not certified with sufficiently trusted signatures!
# gpg:          It is not certain that the signature belongs to the owner.
# Primary key fingerprint: 215D 46F4 8246 689E C77F  3562 EF04 965B 398D 6211

* remotes/jasowang/tags/net-pull-request:
  net: checksum: Introduce fine control over checksum type
  net: checksum: Add IP header checksum calculation
  net: checksum: Skip fragmented IP packets
  net: Fix handling of id in netdev_add and netdev_del

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>


Compare: https://github.com/qemu/qemu/compare/3dcfd4e3f285...31ee895047bd



reply via email to

[Prev in Thread] Current Thread [Next in Thread]