def find_last_ifid(pkt, ext):
    """
    Find the interface a packet came from. Handles both SCION and SIBRA paths.
    """
    assert ext.steady
    if ext.setup:
        # Steady setup packets use SCION paths
        path = pkt.path
        iof = path.get_iof()
        hof = path.get_hof()
        if iof.cons_dir_flag:
            return hof.ingress_if
        else:
            return hof.egress_if
    sof = ext.active_blocks[0].sofs[ext.curr_hop]
    if ext.fwd:
        return sof.ingress
    else:
        return sof.egress