From 58c3a23e4b41752845eb25e1d369bf9468f56285 Mon Sep 17 00:00:00 2001 From: Marek Gradzki Date: Fri, 4 Mar 2016 09:21:24 +0100 Subject: Fix NPE in VppIetfInterfaceListener if Ietf interface is not augumented Change-Id: I9cdfbe67f089c74bf9205e447553b4ae07c2f2c6 Signed-off-by: Marek Gradzki --- .../v3po/impl/VppIetfInterfaceListener.java | 53 ++++++++++++---------- 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/VppIetfInterfaceListener.java b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/VppIetfInterfaceListener.java index 481c0ef60..c45fe1fe1 100644 --- a/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/VppIetfInterfaceListener.java +++ b/v3po/impl/src/main/java/io/fd/honeycomb/v3po/impl/VppIetfInterfaceListener.java @@ -274,7 +274,7 @@ public class VppIetfInterfaceListener implements DataTreeChangeListener 0) { - apiName = "api.swInterfaceSetTable"; - ctxId = api.swInterfaceSetTable(swIfIndex, - (byte)0, /* isIpv6 */ - vrfId); - LOG.info("VPPCFG-INFO: {}({} ([]), 0 /* isIpv6 */, {} /* vrfId */)" - + " : ctxId = {}", apiName, swIfName, swIfIndex, - vrfId, ctxId); - cnt = 0; - rv = -77; - while (rv == -77) { - rv = api.getRetval(ctxId, 1 /* release */); - cnt++; - } - if (rv < 0) { - LOG.warn("VPPCFG-WARNING: api.swInterfaceSetTable() ctxId = {} failed: retval = {}!", ctxId, rv); + + if (vppInterface != null) { // FIXME handle vppInterface==null case in consistent manner + Routing rt = vppInterface.getRouting(); + int vrfId = (rt != null) + ? rt.getVrfId().intValue() + : 0; + LOG.info("VPPCFG-INFO: vrfId = {}", vrfId); + if (vrfId > 0) { + apiName = "api.swInterfaceSetTable"; + ctxId = api.swInterfaceSetTable(swIfIndex, + (byte) 0, /* isIpv6 */ + vrfId); + LOG.info("VPPCFG-INFO: {}({} ([]), 0 /* isIpv6 */, {} /* vrfId */)" + + " : ctxId = {}", apiName, swIfName, swIfIndex, + vrfId, ctxId); + cnt = 0; + rv = -77; + while (rv == -77) { + rv = api.getRetval(ctxId, 1 /* release */); + cnt++; + } + if (rv < 0) { + LOG.warn("VPPCFG-WARNING: api.swInterfaceSetTable() ctxId = {} failed: retval = {}!", ctxId, rv); /* DAW-FIXME: throw exception on failure? */ - } else { - LOG.info("VPPCFG-INFO: {}() ctxId = {} retval = {} after {} tries.", apiName, ctxId, rv, cnt); + } else { + LOG.info("VPPCFG-INFO: {}() ctxId = {} retval = {} after {} tries.", apiName, ctxId, rv, cnt); + } } } -- cgit 1.2.3-korg