diff --git a/test/test_bfd.py b/test/test_bfd.py
index b783224..b56df33 100644
--- a/test/test_bfd.py
+++ b/test/test_bfd.py
@@ -62,36 +62,14 @@
                             session1.bs_index)
 
 
-def create_packet(interface, ttl=255, src_port=50000, **kwargs):
-    p = (Ether(src=interface.remote_mac, dst=interface.local_mac) /
-         IP(src=interface.remote_ip4, dst=interface.local_ip4, ttl=ttl) /
-         UDP(sport=src_port, dport=BFD.udp_dport) /
-         BFD(*kwargs))
-    return p
-
-
-def verify_ip(test, packet, local_ip, remote_ip):
-    """ Verify correctness of IP layer. """
-    ip = packet[IP]
-    test.assert_equal(ip.src, local_ip, "IP source address")
-    test.assert_equal(ip.dst, remote_ip, "IP destination address")
-    test.assert_equal(ip.ttl, 255, "IP TTL")
-
-
-def verify_udp(test, packet):
-    """ Verify correctness of UDP layer. """
-    udp = packet[UDP]
-    test.assert_equal(udp.dport, BFD.udp_dport, "UDP destination port")
-    test.assert_in_range(udp.sport, BFD.udp_sport_min, BFD.udp_sport_max,
-                         "UDP source port")
-
-
 class BFDTestSession(object):
     """ BFD session as seen from test framework side """
 
-    def __init__(self, test, interface, detect_mult=3):
+    def __init__(self, test, interface, af, detect_mult=3):
         self.test = test
+        self.af = af
         self.interface = interface
+        self.udp_sport = 50000
         self.bfd_values = {
             'my_discriminator': 0,
             'desired_min_tx_interval': 100000,
@@ -103,7 +81,22 @@
         self.bfd_values.update(kwargs)
 
     def create_packet(self):
-        packet = create_packet(self.interface)
+        if self.af == AF_INET6:
+            packet = (Ether(src=self.interface.remote_mac,
+                            dst=self.interface.local_mac) /
+                      IPv6(src=self.interface.remote_ip6,
+                           dst=self.interface.local_ip6,
+                           hlim=255) /
+                      UDP(sport=self.udp_sport, dport=BFD.udp_dport) /
+                      BFD())
+        else:
+            packet = (Ether(src=self.interface.remote_mac,
+                            dst=self.interface.local_mac) /
+                      IP(src=self.interface.remote_ip4,
+                         dst=self.interface.local_ip4,
+                         ttl=255) /
+                      UDP(sport=self.udp_sport, dport=BFD.udp_dport) /
+                      BFD())
         self.test.logger.debug("BFD: Creating packet")
         for name, value in self.bfd_values.iteritems():
             self.test.logger.debug("BFD: setting packet.%s=%s", name, value)
@@ -125,41 +118,52 @@
                                "BFD - your discriminator")
 
 
-@unittest.skip("")
-class BFDTestCase(VppTestCase):
-    """Bidirectional Forwarding Detection (BFD)"""
-
-    @classmethod
-    def setUpClass(cls):
-        super(BFDTestCase, cls).setUpClass()
-        try:
-            cls.create_pg_interfaces([0])
-            cls.pg0.config_ip4()
-            cls.pg0.generate_remote_hosts()
-            cls.pg0.configure_ipv4_neighbors()
-            cls.pg0.admin_up()
-            cls.pg0.resolve_arp()
-
-        except Exception:
-            super(BFDTestCase, cls).tearDownClass()
-            raise
-
-    def setUp(self):
-        super(BFDTestCase, self).setUp()
-        self.vapi.want_bfd_events()
-        self.vpp_session = VppBFDUDPSession(
-            self, self.pg0, self.pg0.remote_ip4)
-        self.vpp_session.add_vpp_config()
-        self.vpp_session.admin_up()
-        self.test_session = BFDTestSession(self, self.pg0)
-        self.test_session.update(required_min_rx_interval=100000)
+class BFDCommonCode:
+    """Common code used by both IPv4 and IPv6 Test Cases"""
 
     def tearDown(self):
         self.vapi.collect_events()  # clear the event queue
         if not self.vpp_dead:
             self.vapi.want_bfd_events(enable_disable=0)
             self.vpp_session.remove_vpp_config()
-        super(BFDTestCase, self).tearDown()
+
+    def bfd_session_up(self):
+        self.pg_enable_capture([self.pg0])
+        self.logger.info("BFD: Waiting for slow hello")
+        p, timeout = self.wait_for_bfd_packet(2)
+        self.logger.info("BFD: Sending Init")
+        self.test_session.update(my_discriminator=randint(0, 40000000),
+                                 your_discriminator=p[BFD].my_discriminator,
+                                 state=BFDState.init,
+                                 required_min_rx_interval=100000)
+        self.test_session.send_packet()
+        self.logger.info("BFD: Waiting for event")
+        e = self.vapi.wait_for_event(1, "bfd_udp_session_details")
+        self.verify_event(e, expected_state=BFDState.up)
+        self.logger.info("BFD: Session is Up")
+        self.test_session.update(state=BFDState.up)
+
+    def verify_ip(self, packet):
+        """ Verify correctness of IP layer. """
+        if self.vpp_session.af == AF_INET6:
+            ip = packet[IPv6]
+            local_ip = self.pg0.local_ip6
+            remote_ip = self.pg0.remote_ip6
+            self.assert_equal(ip.hlim, 255, "IPv6 hop limit")
+        else:
+            ip = packet[IP]
+            local_ip = self.pg0.local_ip4
+            remote_ip = self.pg0.remote_ip4
+            self.assert_equal(ip.ttl, 255, "IPv4 TTL")
+        self.assert_equal(ip.src, local_ip, "IP source address")
+        self.assert_equal(ip.dst, remote_ip, "IP destination address")
+
+    def verify_udp(self, packet):
+        """ Verify correctness of UDP layer. """
+        udp = packet[UDP]
+        self.assert_equal(udp.dport, BFD.udp_dport, "UDP destination port")
+        self.assert_in_range(udp.sport, BFD.udp_sport_min, BFD.udp_sport_max,
+                             "UDP source port")
 
     def verify_event(self, event, expected_state):
         """ Verify correctness of event values. """
@@ -198,35 +202,64 @@
         before = time.time()
         p = self.pg0.wait_for_packet(timeout=timeout)
         after = time.time()
+        self.logger.debug(ppp("Got packet:", p))
         bfd = p[BFD]
         if bfd is None:
             raise Exception(ppp("Unexpected or invalid BFD packet:", p))
         if bfd.payload:
             raise Exception(ppp("Unexpected payload in BFD packet:", bfd))
-        verify_ip(self, p, self.pg0.local_ip4, self.pg0.remote_ip4)
-        verify_udp(self, p)
+        self.verify_ip(p)
+        self.verify_udp(p)
         self.test_session.verify_packet(p)
         return p, after - before
 
-    def bfd_session_up(self):
-        self.pg_enable_capture([self.pg0])
-        self.logger.info("BFD: Waiting for slow hello")
-        p, ttp = self.wait_for_bfd_packet()
-        self.logger.info("BFD: Sending Init")
-        self.test_session.update(my_discriminator=randint(0, 40000000),
-                                 your_discriminator=p[BFD].my_discriminator,
-                                 state=BFDState.init)
-        self.test_session.send_packet()
-        self.logger.info("BFD: Waiting for event")
-        e = self.vapi.wait_for_event(1, "bfd_udp_session_details")
-        self.verify_event(e, expected_state=BFDState.up)
-        self.logger.info("BFD: Session is Up")
-        self.test_session.update(state=BFDState.up)
-
     def test_session_up(self):
         """ bring BFD session up """
         self.bfd_session_up()
 
+    def test_hold_up(self):
+        """ hold BFD session up """
+        self.bfd_session_up()
+        for i in range(5):
+            self.wait_for_bfd_packet()
+            self.test_session.send_packet()
+
+
+class BFD4TestCase(VppTestCase, BFDCommonCode):
+    """Bidirectional Forwarding Detection (BFD)"""
+
+    @classmethod
+    def setUpClass(cls):
+        super(BFD4TestCase, cls).setUpClass()
+        try:
+            cls.create_pg_interfaces([0])
+            cls.pg0.config_ip4()
+            cls.pg0.generate_remote_hosts()
+            cls.pg0.configure_ipv4_neighbors()
+            cls.pg0.admin_up()
+            cls.pg0.resolve_arp()
+
+        except Exception:
+            super(BFD4TestCase, cls).tearDownClass()
+            raise
+
+    def setUp(self):
+        super(BFD4TestCase, self).setUp()
+        self.vapi.want_bfd_events()
+        try:
+            self.vpp_session = VppBFDUDPSession(self, self.pg0,
+                                                self.pg0.remote_ip4)
+            self.vpp_session.add_vpp_config()
+            self.vpp_session.admin_up()
+            self.test_session = BFDTestSession(self, self.pg0, AF_INET)
+        except:
+            self.vapi.want_bfd_events(enable_disable=0)
+            raise
+
+    def tearDown(self):
+        BFDCommonCode.tearDown(self)
+        super(BFD4TestCase, self).tearDown()
+
     def test_slow_timer(self):
         """ verify slow periodic control frames while session down """
         self.pg_enable_capture([self.pg0])
@@ -261,13 +294,6 @@
             return
         raise Exception(ppp("Received unexpected BFD packet:", p))
 
-    def test_hold_up(self):
-        """ hold BFD session up """
-        self.bfd_session_up()
-        for i in range(5):
-            self.wait_for_bfd_packet()
-            self.test_session.send_packet()
-
     def test_conn_down(self):
         """ verify session goes down after inactivity """
         self.bfd_session_up()
@@ -324,5 +350,42 @@
                              1.10 * interval / us_in_sec,
                              "time between BFD packets")
 
+
+class BFD6TestCase(VppTestCase, BFDCommonCode):
+    """Bidirectional Forwarding Detection (BFD) (IPv6) """
+
+    @classmethod
+    def setUpClass(cls):
+        super(BFD6TestCase, cls).setUpClass()
+        try:
+            cls.create_pg_interfaces([0])
+            cls.pg0.config_ip6()
+            cls.pg0.configure_ipv6_neighbors()
+            cls.pg0.admin_up()
+            cls.pg0.resolve_ndp()
+
+        except Exception:
+            super(BFD6TestCase, cls).tearDownClass()
+            raise
+
+    def setUp(self):
+        super(BFD6TestCase, self).setUp()
+        self.vapi.want_bfd_events()
+        try:
+            self.vpp_session = VppBFDUDPSession(self, self.pg0,
+                                                self.pg0.remote_ip6,
+                                                af=AF_INET6)
+            self.vpp_session.add_vpp_config()
+            self.vpp_session.admin_up()
+            self.test_session = BFDTestSession(self, self.pg0, AF_INET6)
+            self.logger.debug(self.vapi.cli("show adj nbr"))
+        except:
+            self.vapi.want_bfd_events(enable_disable=0)
+            raise
+
+    def tearDown(self):
+        BFDCommonCode.tearDown(self)
+        super(BFD6TestCase, self).tearDown()
+
 if __name__ == '__main__':
     unittest.main(testRunner=VppTestRunner)
