'Return the sum of the traffic counters of all rules of a chain.'

def get_traffic_counters(self, chain, wrap=True, zero=False):

    cmd_tables = self._get_traffic_counters_cmd_tables(chain, wrap)
    if (not cmd_tables):
        LOG.warning(_LW('Attempted    to    get    traffic    counters    of    chain    %s    which    does    not    exist'), chain)
        return
    name = get_chain_name(chain, wrap)
    acc = {'pkts': 0, 'bytes': 0}
    for (cmd, table) in cmd_tables:
        args = [cmd, '-t', table, '-L', name, '-n', '-v', '-x']
        if zero:
            args.append('-Z')
        if self.namespace:
            args = (['ip', 'netns', 'exec', self.namespace] + args)
        current_table = self.execute(args, run_as_root=True)
        current_lines = current_table.split('\n')
        for line in current_lines[2:]:
            if (not line):
                break
            data = line.split()
            if ((len(data) < 2) or (not data[0].isdigit()) or (not data[1].isdigit())):
                break
            acc['pkts'] += int(data[0])
            acc['bytes'] += int(data[1])
    return acc
