Add simple examples for using pyroute2+tc

* simple_tc shows using just IPRoute
* simple_ipdb shows using IPDB as well, slightly more complicated
 - If the exception handling is done as shown, hangs may result
 - If only IPRoute is used, this shouldn't be the case

Signed-off-by: Brenden Blanco <bblanco@plumgrid.com>
diff --git a/examples/simple_ipdb.py b/examples/simple_ipdb.py
new file mode 100755
index 0000000..d7282ac
--- /dev/null
+++ b/examples/simple_ipdb.py
@@ -0,0 +1,35 @@
+#!/usr/bin/env python
+# Copyright (c) PLUMgrid, Inc.
+# Licensed under the Apache License, Version 2.0 (the "License")
+
+# This example shows how to use pyroute2 to attach a BPF program to an
+# interface. Pyroute2 does contain some quirks with regard to program
+# termination, especially take care when using IPDB and leaving exceptions
+# uncaught (catch them).
+
+from bpf import BPF
+from pyroute2 import IPRoute, IPDB
+
+ipr = IPRoute()
+ipdb = IPDB(nl=ipr)
+
+text = """
+int hello(struct __sk_buff *skb) {
+  return 1;
+}
+"""
+
+try:
+    b = BPF(text=text, debug=0)
+    fn = b.load_func("hello", BPF.SCHED_CLS)
+    ifc = ipdb.create(ifname="t1a", kind="veth", peer="t1b").commit()
+
+    ipr.tc("add", "ingress", ifc["index"], "ffff:")
+    ipr.tc("add-filter", "bpf", ifc["index"], ":1", fd=fn.fd,
+           name=fn.name, parent="ffff:", action="ok", classid=1)
+    ipr.tc("add", "sfq", ifc["index"], "1:")
+    ipr.tc("add-filter", "bpf", ifc["index"], ":1", fd=fn.fd,
+           name=fn.name, parent="1:", action="ok", classid=1)
+finally:
+    if "ifc" in locals(): ifc.remove().commit()
+    ipdb.release()
diff --git a/examples/simple_tc.py b/examples/simple_tc.py
new file mode 100755
index 0000000..f38c98e
--- /dev/null
+++ b/examples/simple_tc.py
@@ -0,0 +1,29 @@
+#!/usr/bin/env python
+# Copyright (c) PLUMgrid, Inc.
+# Licensed under the Apache License, Version 2.0 (the "License")
+
+from bpf import BPF
+from pyroute2 import IPRoute
+
+ipr = IPRoute()
+
+text = """
+int hello(struct __sk_buff *skb) {
+  return 1;
+}
+"""
+
+try:
+    b = BPF(text=text, debug=0)
+    fn = b.load_func("hello", BPF.SCHED_CLS)
+    ipr.link_create(ifname="t1a", kind="veth", peer="t1b")
+    idx = ipr.link_lookup(ifname="t1a")[0]
+
+    ipr.tc("add", "ingress", idx, "ffff:")
+    ipr.tc("add-filter", "bpf", idx, ":1", fd=fn.fd,
+           name=fn.name, parent="ffff:", action="ok", classid=1)
+    ipr.tc("add", "sfq", idx, "1:")
+    ipr.tc("add-filter", "bpf", idx, ":1", fd=fn.fd,
+           name=fn.name, parent="1:", action="ok", classid=1)
+finally:
+    if "idx" in locals(): ipr.link_remove(idx)