Skip to content
Snippets Groups Projects
  1. May 04, 2021
  2. Apr 23, 2021
  3. Apr 08, 2021
  4. Mar 22, 2021
  5. Mar 15, 2021
    • Alexey Kirillov's avatar
      net: Do not fill legacy info_str for backends · f2e8319d
      Alexey Kirillov authored
      
      As we use QAPI NetClientState->stored_config to store and get information
      about backend network devices, we can drop fill of legacy field info_str
      for them.
      
      We still use info_str field for NIC and hubports, so we can not completely
      remove it.
      
      Signed-off-by: default avatarAlexey Kirillov <lekiravi@yandex-team.ru>
      Signed-off-by: default avatarJason Wang <jasowang@redhat.com>
      f2e8319d
    • Alexey Kirillov's avatar
      hmp: Use QAPI NetdevInfo in hmp_info_network · a0724776
      Alexey Kirillov authored
      
      Replace usage of legacy field info_str of NetClientState for backend
      network devices with QAPI NetdevInfo stored_config that already used
      in QMP query-netdev.
      
      This change increases the detail of the "info network" output and takes
      a more general approach to composing the output.
      
      NIC and hubports still use legacy info_str field.
      
      Signed-off-by: default avatarAlexey Kirillov <lekiravi@yandex-team.ru>
      Signed-off-by: default avatarJason Wang <jasowang@redhat.com>
      a0724776
    • Alexey Kirillov's avatar
      net: Move NetClientState.info_str to dynamic allocations · 59b5437e
      Alexey Kirillov authored
      
      The info_str field of the NetClientState structure is static and has a size
      of 256 bytes. This amount is often unclaimed, and the field itself is used
      exclusively for HMP "info network".
      
      The patch translates info_str to dynamic memory allocation.
      
      This action is also allows us to painlessly discard usage of this field
      for backend devices.
      
      Signed-off-by: default avatarAlexey Kirillov <lekiravi@yandex-team.ru>
      Signed-off-by: default avatarJason Wang <jasowang@redhat.com>
      59b5437e
    • Alexey Kirillov's avatar
      qapi: net: Add query-netdev command · d32ad10a
      Alexey Kirillov authored
      
      The query-netdev command is used to get the configuration of the current
      network device backends (netdevs).
      This is the QMP analog of the HMP command "info network" but only for
      netdevs (i.e. excluding NIC and hubports).
      
      The query-netdev command returns an array of objects of the NetdevInfo
      type, which are an extension of Netdev type. It means that response can
      be used for netdev-add after small modification. This can be useful for
      recreate the same netdev configuration.
      
      Information about the network device is filled in when it is created or
      modified and is available through the NetClientState->stored_config.
      
      Signed-off-by: default avatarAlexey Kirillov <lekiravi@yandex-team.ru>
      Acked-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: default avatarJason Wang <jasowang@redhat.com>
      d32ad10a
    • Jason Wang's avatar
      net: introduce qemu_receive_packet() · 705df546
      Jason Wang authored
      
      Some NIC supports loopback mode and this is done by calling
      nc->info->receive() directly which in fact suppresses the effort of
      reentrancy check that is done in qemu_net_queue_send().
      
      Unfortunately we can't use qemu_net_queue_send() here since for
      loopback there's no sender as peer, so this patch introduce a
      qemu_receive_packet() which is used for implementing loopback mode
      for a NIC with this check.
      
      NIC that supports loopback mode will be converted to this helper.
      
      This is intended to address CVE-2021-3416.
      
      Cc: Prasad J Pandit <ppandit@redhat.com>
      Reviewed-by: default avatarPhilippe Mathieu-Daudé <philmd@redhat.com>
      Cc: qemu-stable@nongnu.org
      Signed-off-by: default avatarJason Wang <jasowang@redhat.com>
      705df546
    • Paolo Bonzini's avatar
      net: validate that ids are well formed · e73b4317
      Paolo Bonzini authored
      
      When a network or network device is created from the command line or HMP,
      QemuOpts ensures that the id passes the id_wellformed check.  However,
      QMP skips this:
      
         $ qemu-system-x86_64 -qmp stdio -S -nic user,id=123/456
         qemu-system-x86_64: -nic user,id=123/456: Parameter id expects an identifier
         Identifiers consist of letters, digits, -, ., _, starting with a letter.
      
         $ qemu-system-x86_64 -qmp stdio -S
         {"execute":"qmp_capabilities"}
         {"return": {}}
         {"execute":"netdev_add", "arguments": {"type": "user", "id": "123/456"}}
         {"return": {}}
      
      After:
      
         $ qemu-system-x86_64 -qmp stdio -S
         {"execute":"qmp_capabilities"}
         {"return": {}}
         {"execute":"netdev_add", "arguments": {"type": "user", "id": "123/456"}}
         {"error": {"class": "GenericError", "desc": "Parameter "id" expects an identifier"}}
      
      Validity checks should be performed always at the bottom of the call chain,
      because QMP skips all the steps above.  At the same time we know that every
      call chain should go through either QMP or (for legacy) through QemuOpts.
      Because the id for -net and -nic is automatically generated and not
      well-formed by design, just add the check to QMP.
      
      Cc: Jason Wang <jasowang@redhat.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarJason Wang <jasowang@redhat.com>
      e73b4317
    • Bin Meng's avatar
      net: Fix build error when DEBUG_NET is on · 26d0586f
      Bin Meng authored
      
      "qemu-common.h" should be included to provide the forward declaration
      of qemu_hexdump() when DEBUG_NET is on.
      
      Signed-off-by: default avatarBin Meng <bin.meng@windriver.com>
      Reviewed-by: default avatarPhilippe Mathieu-Daudé <philmd@redhat.com>
      Signed-off-by: default avatarJason Wang <jasowang@redhat.com>
      26d0586f
  6. Mar 09, 2021
  7. Jan 29, 2021
  8. Jan 28, 2021
  9. Jan 25, 2021
    • Bin Meng's avatar
      net: checksum: Introduce fine control over checksum type · f5746335
      Bin Meng authored
      
      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: default avatarBin Meng <bin.meng@windriver.com>
      Signed-off-by: default avatarJason Wang <jasowang@redhat.com>
      f5746335
    • Guishan Qin's avatar
      net: checksum: Add IP header checksum calculation · d97f1159
      Guishan Qin authored
      
      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: default avatarGuishan Qin <guishan.qin@windriver.com>
      Signed-off-by: default avatarYabing Liu <yabing.liu@windriver.com>
      Signed-off-by: default avatarBin Meng <bin.meng@windriver.com>
      Reviewed-by: default avatarCédric Le Goater <clg@kaod.org>
      Signed-off-by: default avatarJason Wang <jasowang@redhat.com>
      d97f1159
    • Markus Carlstedt's avatar
      net: checksum: Skip fragmented IP packets · 0dcf0c0a
      Markus Carlstedt authored
      
      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: default avatarMarkus Carlstedt <markus.carlstedt@windriver.com>
      Signed-off-by: default avatarBin Meng <bin.meng@windriver.com>
      Signed-off-by: default avatarJason Wang <jasowang@redhat.com>
      0dcf0c0a
    • Markus Armbruster's avatar
      net: Fix handling of id in netdev_add and netdev_del · 831734cc
      Markus Armbruster authored
      
      CLI -netdev accumulates in option group "netdev".
      
      Before commit 08712fcb "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 08712fcb 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: default avatarAndrew Melnichenko <andrew@daynix.com>
      Fixes: 08712fcb
      Cc: qemu-stable@nongnu.org
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: default avatarEric Blake <eblake@redhat.com>
      Signed-off-by: default avatarJason Wang <jasowang@redhat.com>
      831734cc
  10. Jan 08, 2021
  11. Dec 15, 2020
  12. Dec 11, 2020
    • Kevin Wolf's avatar
      can-host: Fix crash when 'canbus' property is not set · 7cc25f6c
      Kevin Wolf authored
      
      Providing the 'if' property, but not 'canbus' segfaults like this:
      
       #0  0x0000555555b0f14d in can_bus_insert_client (bus=0x0, client=0x555556aa9af0) at ../net/can/can_core.c:88
       #1  0x00005555559c3803 in can_host_connect (ch=0x555556aa9ac0, errp=0x7fffffffd568) at ../net/can/can_host.c:62
       #2  0x00005555559c386a in can_host_complete (uc=0x555556aa9ac0, errp=0x7fffffffd568) at ../net/can/can_host.c:72
       #3  0x0000555555d52de9 in user_creatable_complete (uc=0x555556aa9ac0, errp=0x7fffffffd5c8) at ../qom/object_interfaces.c:23
      
      Add the missing NULL check.
      
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      Message-Id: <20201130105615.21799-5-kwolf@redhat.com>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      7cc25f6c
Loading