Vehicle-to-everything (V2X) is one of the key applications of upcoming 5G systems. The 5G systems are highly anticipated to adopt software defined network/network function virtualization technology in their core networks as it provides high flexibility and maintainability. However, if the flow tables in switches, called OpenFlow switches, overflow due to excessive policy rules, the networks suffer from large packet delay and frequent packet drops, and fail to support V2X services. To resolve this issue, we propose a new packet classification algorithm that runs fast even with the huge number of policy rules. There is the minimal concern for the overflow in our scheme since it is a pure software-based approach. Furthermore, simulation results show that our algorithm enjoys both the fast packet classification speed and the short policy update time. Thus, our scheme is very suitable for highly dynamic environments like 5G networks.