original_docstring: Add a TAP device to a Linux kernel bridge
  
          Defend against this having been done already (common on restart)
          and this missing a requirement (common when plugging external
          tap interfaces).
          
docstring: Add a TAP device to a Linux kernel bridge
  Defend against this having been done already (common on restart)
  and this missing a requirement (common when plugging external
  tap interfaces).
docstring_tokens: Add a TAP device to a Linux kernel bridge Defend against this having been done already ( common on restart ) and this missing a requirement ( common when plugging external tap interfaces ) .
code: def ensure_tap_in_bridge(self, tap_name, bridge_name):
          """Add a TAP device to a Linux kernel bridge
  
          Defend against this having been done already (common on restart)
          and this missing a requirement (common when plugging external
          tap interfaces).
          """
  
          bridge = bridge_lib.BridgeDevice(bridge_name)
          bridge.set_log_fail_as_error(False)
          if bridge.exists() and ip_lib.device_exists(tap_name) \
             and not bridge.owns_interface(tap_name):
              try:
                  bridge.addif(tap_name)
              except Exception as ex:
                  # External TAP interfaces created by DHCP or L3 agent will be
                  # added to corresponding Linux Bridge by vpp-agent to talk to
                  # VPP. During a regular port binding process, there are two
                  # code paths calling this function for adding the interface to
                  # the Linux Bridge, which may potentially cause a race
                  # condition and a non-harmful traceback in the log. Also, it
                  # is quite possible that a bridge may have been deleted by the
                  # normal port unbinding process before this code tries to add
                  # the tap interafce.
  
                  # The fix will eliminate the non-harmful traceback in the log.
                  match1 = re.search(r"Stderr\: device (vpp|tap)[0-9a-f]{8}-"
                                     "[0-9a-f]{2} is already a member of a "
                                     "bridge; can't enslave it to bridge br-"
                                     r'[0-9a-f]{8}-[0-9a-f]{2}\.', str(ex))
                  match2 = re.search(r"Stderr: Error: argument \"br-"
                                     "[0-9a-f]{8}-[0-9a-f]{2}\" is wrong: "
                                     "Device does not exist", str(ex))
                  if not match1 and not match2:
                      LOG.exception("Can't add interface %s to bridge %s: %s" %
                                    (tap_name, bridge_name, str(ex)))
code_tokens: def ensure_tap_in_bridge ( self , tap_name , bridge_name ) : bridge = bridge_lib . BridgeDevice ( bridge_name ) bridge . set_log_fail_as_error ( False ) if bridge . exists ( ) and ip_lib . device_exists ( tap_name ) and not bridge . owns_interface ( tap_name ) : try : bridge . addif ( tap_name ) except Exception as ex : match1 = re . search ( r"Stderr\: device (vpp|tap)[0-9a-f]{8}-" "[0-9a-f]{2} is already a member of a " "bridge; can't enslave it to bridge br-" r'[0-9a-f]{8}-[0-9a-f]{2}\.' , str ( ex ) ) match2 = re . search ( r"Stderr: Error: argument \"br-" "[0-9a-f]{8}-[0-9a-f]{2}\" is wrong: " "Device does not exist" , str ( ex ) ) if not match1 and not match2 : LOG . exception ( "Can't add interface %s to bridge %s: %s" % ( tap_name , bridge_name , str ( ex ) ) )
short_docstring: Add a TAP device to a Linux kernel bridge
  Defend against this having been done already (common on restart)
  and this missing a requirement (common when plugging external
  tap interfaces).
short_docstring_tokens: Add a TAP device to a Linux kernel bridge Defend against this having been done already ( common on restart ) and this missing a requirement ( common when plugging external tap interfaces ) .
comment: """Add a TAP device to a Linux kernel bridge
  
          Defend against this having been done already (common on restart)
          and this missing a requirement (common when plugging external
          tap interfaces).
          """$SEP$# External TAP interfaces created by DHCP or L3 agent will be$SEP$# added to corresponding Linux Bridge by vpp-agent to talk to$SEP$# VPP. During a regular port binding process, there are two$SEP$# code paths calling this function for adding the interface to$SEP$# the Linux Bridge, which may potentially cause a race$SEP$# condition and a non-harmful traceback in the log. Also, it$SEP$# is quite possible that a bridge may have been deleted by the$SEP$# normal port unbinding process before this code tries to add$SEP$# the tap interafce.$SEP$# The fix will eliminate the non-harmful traceback in the log.