import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
+import javax.annotation.Nullable;
import javax.annotation.PreDestroy;
import javax.inject.Inject;
import javax.inject.Singleton;
}
}
+ @Nullable
private VirtualRouter getRouter(Uuid rtrId) {
return rtrId != null ? vrouters.get(rtrId) : null;
}
}
}
+ @Nullable
private VirtualSubnet getSubnet(Uuid snetId) {
return snetId != null ? vsubnets.get(snetId) : null;
}
}
}
+ @Nullable
private VirtualPort getPort(Uuid portId) {
return portId != null ? vintfs.get(portId) : null;
}
}
}
+ @Nullable
public Set<VirtualPort> removeUnprocessed(Map<Uuid, Set<VirtualPort>> unprocessed, Uuid id) {
if (id != null) {
return unprocessed.remove(id);
return removedSubnets != null ? removedSubnets : Collections.emptySet();
}
+ @Nullable
public VirtualPort getRouterV6InterfaceForNetwork(Uuid networkId) {
LOG.debug("obtaining the virtual interface for {}", networkId);
return networkId != null ? vrouterv6IntfMap.get(networkId) : null;
}
+ @Nullable
public VirtualPort obtainV6Interface(Uuid id) {
VirtualPort intf = getPort(id);
if (intf == null) {
return interfaceName;
}
+ @Nullable
public Long updateNetworkElanTag(Uuid networkId) {
Long elanTag = null;
if (null != this.elanProvider) {
return elanTag;
}
+ @Nullable
private VirtualNetwork getNetwork(Uuid networkId) {
return networkId != null ? vnetworks.get(networkId) : null;
}
+ @Nullable
public Long getNetworkElanTag(Uuid networkId) {
Long elanTag = null;
IVirtualNetwork net = getNetwork(networkId);
private void updateNAResponse(NeighborSolicitationPacket pdu,
VirtualPort port, NeighborAdvertisePacketBuilder naPacket) {
long flag = 0;
- if (!pdu.getSourceIpv6().equals(Ipv6ServiceUtils.UNSPECIFIED_ADDR)) {
+ if (!Ipv6ServiceUtils.UNSPECIFIED_ADDR.equals(pdu.getSourceIpv6())) {
naPacket.setDestinationIpv6(pdu.getSourceIpv6());
flag = 0xE0; // Set Router, Solicited and Override Flag.
} else {
package org.opendaylight.netvirt.ipv6service;
import static java.util.Objects.requireNonNull;
+import static org.opendaylight.netvirt.ipv6service.utils.Ipv6ServiceUtils.nullToEmpty;
import java.math.BigInteger;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import javax.annotation.Nullable;
import org.opendaylight.genius.ipv6util.api.Icmpv6Type;
import org.opendaylight.genius.ipv6util.api.Ipv6Constants;
import org.opendaylight.genius.ipv6util.api.Ipv6Constants.Ipv6RouterAdvertisementType;
}
public boolean transmitRtrAdvertisement(Ipv6RouterAdvertisementType raType, VirtualPort routerPort,
- long elanTag, RouterSolicitationPacket rsPdu,
+ long elanTag, @Nullable RouterSolicitationPacket rsPdu,
BigInteger dpnId, Uuid port) {
RouterAdvertisementPacketBuilder raPacket = new RouterAdvertisementPacketBuilder();
updateRAResponse(raType, rsPdu, raPacket, routerPort);
return true;
}
- private static void updateRAResponse(Ipv6RouterAdvertisementType raType, RouterSolicitationPacket pdu,
+ private static void updateRAResponse(Ipv6RouterAdvertisementType raType, @Nullable RouterSolicitationPacket pdu,
RouterAdvertisementPacketBuilder raPacket,
VirtualPort routerPort) {
short icmpv6RaFlags = 0;
MacAddress sourceMac = MacAddress.getDefaultInstance(gatewayMac);
raPacket.setSourceMac(sourceMac);
if (raType == Ipv6RouterAdvertisementType.SOLICITED_ADVERTISEMENT) {
+ if (pdu == null) {
+ throw new IllegalArgumentException("Null pdu for solicited advertisement");
+ }
raPacket.setDestinationMac(pdu.getSourceMac());
raPacket.setDestinationIpv6(pdu.getSourceIpv6());
raPacket.setFlowLabel(pdu.getFlowLabel());
}
raPacket.setPrefixList(prefixList);
-
- return;
}
private byte[] fillRouterAdvertisementPacket(RouterAdvertisementPacket pdu) {
buf.put((byte)pdu.getSourceAddrLength().shortValue());
buf.put(Ipv6Util.bytesFromHexString(pdu.getSourceLlAddress().getValue()));
- for (PrefixList prefix : pdu.getPrefixList()) {
+ for (PrefixList prefix : nullToEmpty(pdu.getPrefixList())) {
buf.put((byte)prefix.getOptionType().shortValue());
buf.put((byte)prefix.getOptionLength().shortValue());
buf.put((byte)prefix.getPrefixLength().shortValue());
*/
package org.opendaylight.netvirt.ipv6service;
+import static org.opendaylight.netvirt.ipv6service.utils.Ipv6ServiceUtils.nullToEmpty;
+
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
+import javax.annotation.Nullable;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import javax.inject.Singleton;
@Override
protected void add(InstanceIdentifier<Port> identifier, Port port) {
- if (port.getDeviceOwner().equalsIgnoreCase(Ipv6ServiceConstants.NETWORK_ROUTER_GATEWAY)) {
+ if (Ipv6ServiceConstants.NETWORK_ROUTER_GATEWAY.equalsIgnoreCase(port.getDeviceOwner())) {
// Todo: revisit when IPv6 north-south support is implemented.
LOG.info("IPv6Service (TODO): Skipping router_gateway port {} for add event", port);
return;
}
- if (port.getDeviceOwner().equalsIgnoreCase(Ipv6ServiceConstants.DEVICE_OWNER_DHCP)) {
+ if (Ipv6ServiceConstants.DEVICE_OWNER_DHCP.equalsIgnoreCase(port.getDeviceOwner())) {
LOG.info("IPv6Service: Skipping network_dhcp port {} for add event", port);
return;
}
LOG.debug("Add port notification handler is invoked for port {} ", port);
- List<FixedIps> ipList = port.getFixedIps();
- for (FixedIps fixedip : ipList) {
+ for (FixedIps fixedip : nullToEmpty(port.getFixedIps())) {
if (fixedip.getIpAddress().getIpv4Address() != null) {
continue;
}
@Override
protected void remove(InstanceIdentifier<Port> identifier, Port port) {
- if (port.getDeviceOwner().equalsIgnoreCase(Ipv6ServiceConstants.NETWORK_ROUTER_GATEWAY)) {
+ if (Ipv6ServiceConstants.NETWORK_ROUTER_GATEWAY.equalsIgnoreCase(port.getDeviceOwner())) {
// Todo: revisit when IPv6 north-south support is implemented.
LOG.info("IPv6Service (TODO): Skipping router_gateway port {} for remove event", port);
return;
}
- if (port.getDeviceOwner().equalsIgnoreCase(Ipv6ServiceConstants.DEVICE_OWNER_DHCP)) {
+ if (Ipv6ServiceConstants.DEVICE_OWNER_DHCP.equalsIgnoreCase(port.getDeviceOwner())) {
LOG.info("IPv6Service: Skipping network_dhcp port {} for remove event", port);
return;
}
@Override
protected void update(InstanceIdentifier<Port> identifier, Port original, Port update) {
- if (update.getDeviceOwner().equalsIgnoreCase(Ipv6ServiceConstants.NETWORK_ROUTER_GATEWAY)) {
+ if (Ipv6ServiceConstants.NETWORK_ROUTER_GATEWAY.equalsIgnoreCase(update.getDeviceOwner())) {
// Todo: revisit when IPv6 north-south support is implemented.
LOG.info("IPv6Service (TODO): Skipping router_gateway port {} for update event", update);
return;
}
- if (update.getDeviceOwner().equalsIgnoreCase(Ipv6ServiceConstants.DEVICE_OWNER_DHCP)) {
+ if (Ipv6ServiceConstants.DEVICE_OWNER_DHCP.equalsIgnoreCase(update.getDeviceOwner())) {
LOG.info("IPv6Service: Skipping network_dhcp port {} for update event", update);
return;
}
}
protected void addInterfaceInfo(Port port, FixedIps fixedip) {
- if (port.getDeviceOwner().equalsIgnoreCase(Ipv6ServiceConstants.NETWORK_ROUTER_INTERFACE)) {
+ if (Ipv6ServiceConstants.NETWORK_ROUTER_INTERFACE.equalsIgnoreCase(port.getDeviceOwner())) {
LOG.info("IPv6: addInterfaceInfo is invoked for a router interface {}, fixedIp: {}", port, fixedip);
// Add router interface
ifMgr.addRouterIntf(port.getUuid(),
}
}
- private Set<FixedIps> getFixedIpSet(List<FixedIps> fixedIps) {
+ private Set<FixedIps> getFixedIpSet(@Nullable List<FixedIps> fixedIps) {
return fixedIps != null ? new HashSet<>(fixedIps) : Collections.emptySet();
}
import java.util.concurrent.ConcurrentMap;
import java.util.stream.Collectors;
import java.util.stream.Stream;
+import javax.annotation.Nullable;
import org.opendaylight.genius.ipv6util.api.Ipv6Util;
import org.opendaylight.netvirt.ipv6service.api.IVirtualNetwork;
import org.opendaylight.netvirt.ipv6service.utils.Ipv6ServiceConstants;
return dpnIfaceList.values();
}
+ @Nullable
public DpnInterfaceInfo getDpnIfaceInfo(BigInteger dpId) {
return dpId != null ? dpnIfaceList.get(dpId) : null;
}
package org.opendaylight.netvirt.ipv6service.utils;
+import static java.util.Collections.emptyList;
+
import com.google.common.base.Optional;
import java.math.BigInteger;
import java.net.InetAddress;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.ExecutionException;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.apache.commons.lang3.StringUtils;
public static final Ipv6Address ALL_NODES_MCAST_ADDR = newIpv6Address(Ipv6Constants.ALL_NODES_MCAST_ADDRESS);
public static final Ipv6Address UNSPECIFIED_ADDR = newIpv6Address("0:0:0:0:0:0:0:0");
+ @Nullable
private static Ipv6Address newIpv6Address(String ip) {
try {
return Ipv6Address.getDefaultInstance(InetAddress.getByName(ip).getHostAddress());
* @param interfaceName the interface name
* @return the interface.
*/
+ @Nullable
public org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces
.Interface getInterface(String interfaceName) {
- Optional<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces
- .Interface> optInterface =
- read(LogicalDatastoreType.CONFIGURATION, getInterfaceIdentifier(interfaceName));
- if (optInterface.isPresent()) {
- return optInterface.get();
- }
- return null;
+ return read(LogicalDatastoreType.CONFIGURATION, getInterfaceIdentifier(interfaceName)).orNull();
}
/**
* @param interfaceName the interface name.
* @return the interface state.
*/
+ @Nullable
public org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state
.Interface getInterfaceStateFromOperDS(String interfaceName) {
- InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508
- .interfaces.state.Interface> ifStateId = buildStateInterfaceId(interfaceName);
- return MDSALUtil.read(LogicalDatastoreType.OPERATIONAL, ifStateId, broker).orNull();
+ return MDSALUtil.read(LogicalDatastoreType.OPERATIONAL, buildStateInterfaceId(interfaceName), broker).orNull();
}
private static List<MatchInfo> getIcmpv6RSMatch(Long elanTag) {
NwConstants.IPV6_SERVICE_INDEX)));
}
+ @Nullable
public BigInteger getDpIdFromInterfaceState(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf
.interfaces.rev140508.interfaces.state.Interface interfaceState) {
BigInteger dpId = null;
}
return subnet.getIpVersion().equals(Ipv6ServiceConstants.IP_VERSION_V6) ? true : false;
}
+
+ // TODO Replace this with mdsal's DataObjectUtils.nullToEmpty when upgrading to mdsal 3
+ @Nonnull
+ public static <T> List<T> nullToEmpty(final @Nullable List<T> input) {
+ return input != null ? input : emptyList();
+ }
}
import java.util.List;
import java.util.stream.Collectors;
+import javax.annotation.Nullable;
import org.apache.karaf.shell.commands.Argument;
import org.apache.karaf.shell.commands.Command;
import org.apache.karaf.shell.console.OsgiCommandSupport;
}
@Override
+ @Nullable
protected Object doExecute() {
TablePrinter tp = new TablePrinter();